Commit de1fce6
committed
fix: complete the ecosystem-case split (URL titlecase, storage lowercase)
The previous "lowercase Maven" commit (1d77fd3) was incomplete:
versionCompare.compareVersion still keyed on 'Maven' (titlecase) so
deriveCriticalFlag's lowercase 'maven' fell through to the null
branch, isInRange treated every Maven range as "no match," and
Maven packages could not have has_critical_vulnerability flipped
TRUE. The same commit also lowercased OSV_ECOSYSTEMS in the env,
which broke the OSV bucket URL (Maven/all.zip is case-sensitive on
the GCS side — maven/all.zip 404s).
Cursor and Copilot both caught this on the latest push; 8 bot
threads were filed against the partial fix. This commit closes
all of them.
Changes:
- versionCompare.ts: compareVersion now matches lowercase 'maven'
per ADR-0001 §OSV. compareMaven returns null for empty / punctuation-
only input (Cursor 3312194073) so isInRange treats unparseable
versions as "no match" rather than silently ordering them as 0.
- versionCompare.ts callers were already lowercase (deriveCriticalFlag
via the packages-db column, parseOsvRecord via the .toLowerCase()
at the OSV boundary). No change needed there.
- activities.ts: requirePositiveInt env validator replaces parseInt,
fails fast on non-numeric or <= 0 input so an upstream typo can't
silently turn into NaN flush-thresholds or LIMIT NaN SQL.
- activities.ts: the allowlist is built from
allowedEcosystems.map(toLowerCase) so the activity layer keeps the
caller-supplied ecosystem (used as a case-sensitive bucket URL
segment) separate from the lowercase matching set used by
parseOsvRecord.
- .env.dist.local: OSV_ECOSYSTEMS back to npm,Maven (OSV's canonical
bucket case). Comment clarifies that the URL is case-sensitive
while the allowlist + DB storage normalize to lowercase internally.
- workflows.ts: comment now states the dual handling explicitly so
the next reader doesn't trip on the same casing seam.
- versionCompare.test.ts: 19 Maven test cases moved to 'maven'
matching production; +3 cases pinning the new compareMaven null
contract (empty, swap empty, '...'); +1 regression guard rejecting
titlecase 'Maven' through compareVersion so a future "forgot to
lowercase" caller fails loudly instead of silently missing
vulnerabilities.
- deriveCriticalFlag.integration.test.ts: finalQuirk fixture moved
to 'maven' to match what production stores.
All 70 unit tests pass.
Signed-off-by: Joan Reyero <joan@reyero.io>1 parent 1d77fd3 commit de1fce6
6 files changed
Lines changed: 63 additions & 13 deletions
File tree
- backend
- services/apps/packages_worker/src/osv
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
188 | 192 | | |
189 | | - | |
| 193 | + | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
Lines changed: 20 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
| |||
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
69 | 86 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
| |||
66 | 79 | | |
67 | 80 | | |
68 | 81 | | |
69 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | 88 | | |
72 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
| |||
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
118 | 127 | | |
119 | 128 | | |
120 | | - | |
| 129 | + | |
121 | 130 | | |
122 | 131 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
34 | 37 | | |
35 | 38 | | |
36 | 39 | | |
| |||
0 commit comments