Commit 941e504
authored
feat: rewrite affected version parser to match
This overhauls our version constraints parser to ensure we're performing
almost in accordance with
[composer](https://getcomposer.org/doc/articles/versions.md) and with
support for surfacing warnings so that we can identify invalid versions
to get addressed upstream.
The primary difference in how we parse versions compared with `composer`
is that we assume a lack of stability constraint means `stable` in all
cases, instead of being [dependent on the
operator](https://getcomposer.org/doc/articles/versions.md#stability-constraints)
- ideally, the stability should be included as part of the constraint
which might be something we can convince the upstream to do, but for now
I've chosen to differ for a few key reasons:
1. Drupal security advisories generally only cover stable versions, so
it's reasonable to assume whoever wrote the version constraints for a
particular advisory was only thinking about stable versions
2. Being semantically correct would mean a _lot_ of changes to our
advisories
3. Ideally we want to be referring versions that actually exist, which
is most likely the case for the versions explicitly mentioned in
particular version constraints (in part because of point 1.), whereas if
we follow the spec we'd have to assume a lot of the time that there's a
`-dev` version that probably won't exist
I have done the implementation to first be spec-compliant, and then
modified it to reflect the above, meaning we should be able to easily
change back in future if needed by reviewing the last handful of commits
on this branch.
I've not actually wired anything up to use the warnings returned by the
parser given the size of this patch already, but they are asserted by
our new test suite.
There's definitely some cleanup worth doing with the implementation, in
particular I probably should have named the component properties
`major`, `minor`, and `patch`, but I'm going to try tackle most of those
as a follow-up since everything is working and renaming things might
make it harder to review the individual commits, and this should be
stable enough to let us progress to the next phase where we'll be
engaging with the Drupal community to improve the advisory data which
should feed back heavily into how robust this implementation actually
needs to becomposer and report warnings about invalid versions (#35)1 parent fde5857 commit 941e504
33 files changed
Lines changed: 895 additions & 41 deletions
File tree
- .github/workflows
- advisories
- acquia_dam
- admin_toolbar
- ai
- core
- diff
- domain_group
- eca
- examples
- file_extractor
- graphql
- group
- imagecache_external
- jsonapi
- oauth_server_sso
- persistent_login
- profile
- protected_pages
- social
- spamspan
- subgroup
- svg_formatter
- symfony_mailer
- tfa
- webform
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
49 | 64 | | |
50 | 65 | | |
51 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
6 | 14 | | |
7 | 15 | | |
8 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
48 | 54 | | |
49 | 55 | | |
50 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
61 | 70 | | |
62 | 71 | | |
63 | 72 | | |
| |||
69 | 78 | | |
70 | 79 | | |
71 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
72 | 84 | | |
73 | 85 | | |
74 | 86 | | |
| |||
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
83 | 98 | | |
84 | 99 | | |
85 | 100 | | |
| |||
91 | 106 | | |
92 | 107 | | |
93 | 108 | | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
94 | 112 | | |
95 | 113 | | |
96 | 114 | | |
| |||
102 | 120 | | |
103 | 121 | | |
104 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
105 | 126 | | |
106 | 127 | | |
107 | 128 | | |
| |||
113 | 134 | | |
114 | 135 | | |
115 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
116 | 140 | | |
117 | 141 | | |
118 | 142 | | |
| |||
124 | 148 | | |
125 | 149 | | |
126 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
127 | 154 | | |
128 | 155 | | |
129 | 156 | | |
| |||
135 | 162 | | |
136 | 163 | | |
137 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
138 | 168 | | |
139 | 169 | | |
140 | 170 | | |
| |||
146 | 176 | | |
147 | 177 | | |
148 | 178 | | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
149 | 182 | | |
150 | 183 | | |
151 | 184 | | |
| |||
157 | 190 | | |
158 | 191 | | |
159 | 192 | | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
160 | 196 | | |
161 | 197 | | |
162 | 198 | | |
| |||
168 | 204 | | |
169 | 205 | | |
170 | 206 | | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
171 | 210 | | |
172 | 211 | | |
173 | 212 | | |
| |||
179 | 218 | | |
180 | 219 | | |
181 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
182 | 224 | | |
183 | 225 | | |
184 | 226 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
0 commit comments