Skip to content

Commit 17b099c

Browse files
ruromeroclaude
andcommitted
fix(python): fix marker evaluator bugs and update test fixtures
- Return false when python version is unknown instead of true, so version-guarded deps are excluded rather than silently included - Track quote state in splitLogical to avoid mis-parsing parentheses inside quoted strings (e.g. platform_version == "10.0 (Build 19045)") - Update expected SBOM fixtures to exclude win32-only packages (pywin32, colorama) that are now correctly filtered on Linux/macOS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2cb2b5a commit 17b099c

11 files changed

Lines changed: 1226 additions & 1326 deletions

File tree

src/providers/marker_evaluator.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function compareVersions(left, right) {
5050
function evaluateComparison(variable, op, value, env) {
5151
let envVal = env[variable]
5252
if (envVal === undefined || envVal === '') {
53-
return variable.includes('version') ? true : false
53+
return false
5454
}
5555

5656
let isVersion = variable.includes('version')
@@ -129,16 +129,30 @@ function splitLogical(expr, sep) {
129129
let depth = 0
130130
let current = ''
131131
let i = 0
132+
let quoteChar = null
132133
while (i < expr.length) {
133-
if (expr[i] === '(') { depth++ }
134-
if (expr[i] === ')') { depth-- }
134+
let ch = expr[i]
135+
if (quoteChar) {
136+
if (ch === quoteChar) { quoteChar = null }
137+
current += ch
138+
i++
139+
continue
140+
}
141+
if (ch === '"' || ch === "'") {
142+
quoteChar = ch
143+
current += ch
144+
i++
145+
continue
146+
}
147+
if (ch === '(') { depth++ }
148+
if (ch === ')') { depth-- }
135149
if (depth === 0 && expr.substring(i, i + sep.length) === sep) {
136150
parts.push(current)
137151
current = ''
138152
i += sep.length
139153
continue
140154
}
141-
current += expr[i]
155+
current += ch
142156
i++
143157
}
144158
parts.push(current)
Lines changed: 58 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,60 @@
11
{
2-
"bomFormat": "CycloneDX",
3-
"specVersion": "1.4",
4-
"version": 1,
5-
"metadata": {
6-
"timestamp": "2023-10-01T00:00:00.000Z",
7-
"component": {
8-
"name": "test-project",
9-
"version": "1.0.0",
10-
"purl": "pkg:pypi/test-project@1.0.0",
11-
"type": "application",
12-
"bom-ref": "pkg:pypi/test-project@1.0.0"
13-
}
14-
},
15-
"components": [
16-
{
17-
"name": "flask",
18-
"version": "2.0.3",
19-
"purl": "pkg:pypi/flask@2.0.3",
20-
"type": "library",
21-
"bom-ref": "pkg:pypi/flask@2.0.3"
22-
},
23-
{
24-
"name": "pywin32",
25-
"version": "311",
26-
"purl": "pkg:pypi/pywin32@311",
27-
"type": "library",
28-
"bom-ref": "pkg:pypi/pywin32@311"
29-
},
30-
{
31-
"name": "requests",
32-
"version": "2.25.1",
33-
"purl": "pkg:pypi/requests@2.25.1",
34-
"type": "library",
35-
"bom-ref": "pkg:pypi/requests@2.25.1"
36-
},
37-
{
38-
"name": "typing-extensions",
39-
"version": "4.1.1",
40-
"purl": "pkg:pypi/typing-extensions@4.1.1",
41-
"type": "library",
42-
"bom-ref": "pkg:pypi/typing-extensions@4.1.1"
43-
}
44-
],
45-
"dependencies": [
46-
{
47-
"ref": "pkg:pypi/test-project@1.0.0",
48-
"dependsOn": [
49-
"pkg:pypi/flask@2.0.3",
50-
"pkg:pypi/pywin32@311",
51-
"pkg:pypi/requests@2.25.1",
52-
"pkg:pypi/typing-extensions@4.1.1"
53-
]
54-
},
55-
{
56-
"ref": "pkg:pypi/flask@2.0.3",
57-
"dependsOn": []
58-
},
59-
{
60-
"ref": "pkg:pypi/pywin32@311",
61-
"dependsOn": []
62-
},
63-
{
64-
"ref": "pkg:pypi/requests@2.25.1",
65-
"dependsOn": []
66-
},
67-
{
68-
"ref": "pkg:pypi/typing-extensions@4.1.1",
69-
"dependsOn": []
70-
}
71-
]
2+
"bomFormat": "CycloneDX",
3+
"specVersion": "1.4",
4+
"version": 1,
5+
"metadata": {
6+
"timestamp": "2023-10-01T00:00:00.000Z",
7+
"component": {
8+
"name": "test-project",
9+
"version": "1.0.0",
10+
"purl": "pkg:pypi/test-project@1.0.0",
11+
"type": "application",
12+
"bom-ref": "pkg:pypi/test-project@1.0.0"
13+
}
14+
},
15+
"components": [
16+
{
17+
"name": "flask",
18+
"version": "2.0.3",
19+
"purl": "pkg:pypi/flask@2.0.3",
20+
"type": "library",
21+
"bom-ref": "pkg:pypi/flask@2.0.3"
22+
},
23+
{
24+
"name": "requests",
25+
"version": "2.25.1",
26+
"purl": "pkg:pypi/requests@2.25.1",
27+
"type": "library",
28+
"bom-ref": "pkg:pypi/requests@2.25.1"
29+
},
30+
{
31+
"name": "typing-extensions",
32+
"version": "4.1.1",
33+
"purl": "pkg:pypi/typing-extensions@4.1.1",
34+
"type": "library",
35+
"bom-ref": "pkg:pypi/typing-extensions@4.1.1"
36+
}
37+
],
38+
"dependencies": [
39+
{
40+
"ref": "pkg:pypi/test-project@1.0.0",
41+
"dependsOn": [
42+
"pkg:pypi/flask@2.0.3",
43+
"pkg:pypi/requests@2.25.1",
44+
"pkg:pypi/typing-extensions@4.1.1"
45+
]
46+
},
47+
{
48+
"ref": "pkg:pypi/flask@2.0.3",
49+
"dependsOn": []
50+
},
51+
{
52+
"ref": "pkg:pypi/requests@2.25.1",
53+
"dependsOn": []
54+
},
55+
{
56+
"ref": "pkg:pypi/typing-extensions@4.1.1",
57+
"dependsOn": []
58+
}
59+
]
7260
}

0 commit comments

Comments
 (0)