Skip to content

Commit 5b2b45c

Browse files
fix: reachability rendering
1 parent bc8dd7a commit 5b2b45c

File tree

11 files changed

+81
-17
lines changed

11 files changed

+81
-17
lines changed

internal/commands/ostest/__snapshots__/sbom_reachability_flow_test.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"packageManager": "npm",
6666
"packageName": "foo",
6767
"publicationTime": "2025-07-28T17:11:43.000000Z",
68-
"reachability": "REACHABLE",
68+
"reachability": "function",
6969
"riskScore": 80,
7070
"severity": "high",
7171
"socialTrendAlert": false,

internal/legacy/definitions/legacy-json.tsp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ enum VulnerabilitySeverity {
1717
}
1818

1919
enum Reachability {
20-
REACHABLE,
21-
NOT_REACHABLE,
20+
function,
21+
package,
22+
`no-info`,
23+
`not-applicable`,
24+
}
25+
26+
model ReachableFunctionPaths {
27+
functionName: string;
28+
callPaths: string[][];
29+
}
30+
31+
model ReachablePaths {
32+
pathCount: uint32;
33+
paths: ReachableFunctionPaths[];
2234
}
2335

2436
alias UpgradePath = string | boolean;
@@ -75,6 +87,7 @@ model Vulnerability {
7587
riskScore?: uint16;
7688
from: string[];
7789
reachability?: Reachability;
90+
reachablePaths?: ReachablePaths;
7891
upgradePath: UpgradePath[];
7992
isUpgradable: boolean;
8093
isPatchable: boolean;

internal/legacy/definitions/oapi.gen.go

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/legacy/definitions/spec.yaml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,37 @@ components:
334334
Reachability:
335335
type: string
336336
enum:
337-
- REACHABLE
338-
- NOT_REACHABLE
337+
- function
338+
- package
339+
- no-info
340+
- not-applicable
341+
ReachableFunctionPaths:
342+
type: object
343+
required:
344+
- functionName
345+
- callPaths
346+
properties:
347+
functionName:
348+
type: string
349+
callPaths:
350+
type: array
351+
items:
352+
type: array
353+
items:
354+
type: string
355+
ReachablePaths:
356+
type: object
357+
required:
358+
- pathCount
359+
- paths
360+
properties:
361+
pathCount:
362+
type: integer
363+
format: uint32
364+
paths:
365+
type: array
366+
items:
367+
$ref: '#/components/schemas/ReachableFunctionPaths'
339368
Reference:
340369
type: object
341370
required:
@@ -492,6 +521,8 @@ components:
492521
type: string
493522
reachability:
494523
$ref: '#/components/schemas/Reachability'
524+
reachablePaths:
525+
$ref: '#/components/schemas/ReachablePaths'
495526
upgradePath:
496527
type: array
497528
items:

internal/legacy/transform/__snapshots__/TestFindingToLegacyVulns_MultipleInstructions_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@
5757
Type: &"license",
5858
UpgradePath: nil,
5959
Version: "1.0.0",
60+
ReachablePaths: (*definitions.ReachablePaths)(nil),
6061
},
6162
}

internal/legacy/transform/__snapshots__/TestFindingToLegacyVulns_NoInstructions_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,6 @@
5454
Type: &"license",
5555
UpgradePath: nil,
5656
Version: "3.2.1",
57+
ReachablePaths: (*definitions.ReachablePaths)(nil),
5758
},
5859
}

internal/legacy/transform/__snapshots__/TestFindingToLegacyVulns_SingleInstruction_1.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@
5656
Type: &"license",
5757
UpgradePath: nil,
5858
Version: "2.5.0",
59+
ReachablePaths: (*definitions.ReachablePaths)(nil),
5960
},
6061
}

internal/legacy/transform/remediation_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func Test_RemediationSummaryToLegacy(t *testing.T) {
209209
PackageName: util.Ptr("baz"),
210210
Version: "1.0.0",
211211
IsUpgradable: false,
212-
Reachability: util.Ptr(definitions.REACHABLE),
212+
Reachability: util.Ptr(definitions.Function),
213213
CvssScore: util.Ptr(float32(9.7)),
214214
Severity: definitions.Critical,
215215
ModificationTime: util.Ptr("2025-06-03T10:14:39Z"),
@@ -270,7 +270,7 @@ func Test_RemediationSummaryToLegacy(t *testing.T) {
270270
PackageName: util.Ptr("baz"),
271271
Version: "1.0.0",
272272
IsUpgradable: false,
273-
Reachability: util.Ptr(definitions.REACHABLE),
273+
Reachability: util.Ptr(definitions.Function),
274274
CvssScore: util.Ptr(float32(9.7)),
275275
Severity: definitions.Critical,
276276
ModificationTime: util.Ptr("2025-06-03T10:14:39Z"),
@@ -284,7 +284,7 @@ func Test_RemediationSummaryToLegacy(t *testing.T) {
284284
PackageName: util.Ptr("foo"),
285285
Version: "1.0.0",
286286
IsUpgradable: true,
287-
Reachability: util.Ptr(definitions.REACHABLE),
287+
Reachability: util.Ptr(definitions.Function),
288288
CvssScore: util.Ptr(float32(7.7)),
289289
Severity: definitions.High,
290290
ModificationTime: util.Ptr("2025-06-03T10:14:39Z"),

internal/legacy/transform/transform.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,12 @@ func ProcessEvidenceForFinding(vuln *definitions.Vulnerability, ev *testapi.Evid
311311
}
312312
switch reachEvidence.Reachability {
313313
case testapi.ReachabilityTypeFunction:
314-
vuln.Reachability = util.Ptr(definitions.REACHABLE)
314+
vuln.Reachability = util.Ptr(definitions.Function)
315315
case testapi.ReachabilityTypeNoInfo:
316-
vuln.Reachability = util.Ptr(definitions.NOTREACHABLE)
317-
case testapi.ReachabilityTypeNotApplicable, testapi.ReachabilityTypeNone:
316+
vuln.Reachability = util.Ptr(definitions.NoInfo)
317+
case testapi.ReachabilityTypeNotApplicable:
318+
vuln.Reachability = util.Ptr(definitions.NotApplicable)
319+
default:
318320
// No reachability value set for these types
319321
}
320322
}

internal/legacy/transform/transform_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ func TestProcessingEvidenceForFinding(t *testing.T) {
203203
{depPathEv, testDepList, nil, false},
204204
{execFlowEv, nil, nil, false}, // Exec flow not yet supported.
205205
{otherFlowEv, nil, nil, false}, // Other flow not yet supported.
206-
{reachableEv, nil, util.Ptr(definitions.REACHABLE), false},
207-
{notReachableEv, nil, util.Ptr(definitions.NOTREACHABLE), false},
206+
{reachableEv, nil, util.Ptr(definitions.Function), false},
207+
{notReachableEv, nil, util.Ptr(definitions.NoInfo), false},
208208
}
209209

210210
for _, tt := range tests {

0 commit comments

Comments
 (0)