@opensip-cli/tool-trivy 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +8 -0
- package/README.md +33 -0
- package/dist/__tests__/tool.test.d.ts +19 -0
- package/dist/__tests__/tool.test.d.ts.map +1 -0
- package/dist/__tests__/tool.test.js +234 -0
- package/dist/__tests__/tool.test.js.map +1 -0
- package/dist/__tests__/worker-e2e.test.d.ts +32 -0
- package/dist/__tests__/worker-e2e.test.d.ts.map +1 -0
- package/dist/__tests__/worker-e2e.test.js +339 -0
- package/dist/__tests__/worker-e2e.test.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/tool.d.ts +87 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +152 -0
- package/dist/tool.js.map +1 -0
- package/package.json +133 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
OpenSIP CLI
|
|
2
|
+
Copyright 2026 opensip-ai
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
5
|
+
this software except in compliance with the License. A copy of the License is
|
|
6
|
+
included in the LICENSE file and is also available at:
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!-- Generated by scripts/build-package-readmes.mjs — do not edit by hand.
|
|
2
|
+
Change the package's "description" (or the generator template) and run
|
|
3
|
+
`pnpm docs:readmes`. CI enforces sync via `pnpm docs:readmes:check`. -->
|
|
4
|
+
|
|
5
|
+
# @opensip-cli/tool-trivy
|
|
6
|
+
|
|
7
|
+
> External Tool Adapter for Trivy — wraps the trivy vulnerability + misconfiguration scanner as an opensip-cli tool (opensip trivy)
|
|
8
|
+
|
|
9
|
+
This package is the **engine** behind a first-party `opensip-cli` tool. The CLI bundles it — you do not normally install it directly.
|
|
10
|
+
|
|
11
|
+
Part of [**opensip-cli**](https://github.com/opensip-ai/opensip-cli) — an open-source codebase intelligence CLI: fitness checks (`fit`), static call-graph analysis (`graph`), simulation (`sim`), and advisory reduction audits (`yagni`).
|
|
12
|
+
|
|
13
|
+
**Distribution model:** the published `opensip-cli` npm package is a full-stack bundle of first-party tools, check packs, and language adapters. Third-party tools install separately via the `opensipTools` manifest and host allowlist; a slim install without bundled tools is not a current goal.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
Most users install the CLI, which bundles the first-party tools:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
curl -fsSL https://opensip.ai/cli/install.sh | bash
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This package is published for the CLI and advanced plugin authors; most users should not install `@opensip-cli/tool-trivy` directly.
|
|
24
|
+
|
|
25
|
+
## Documentation
|
|
26
|
+
|
|
27
|
+
- 📚 Project docs: https://opensip.ai/docs/opensip-cli/
|
|
28
|
+
- 🧭 Package catalog (what every package does): https://github.com/opensip-ai/opensip-cli/blob/v0.1.15/docs/public/70-reference/02-package-catalog.md
|
|
29
|
+
- 📦 Source: https://github.com/opensip-ai/opensip-cli/tree/v0.1.15/packages/tool-trivy
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
Apache-2.0 © opensip-ai
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier-1 (in-process) tests for the trivy adapter `Tool` (ADR-0090 D6 Tier 1).
|
|
3
|
+
*
|
|
4
|
+
* Trivy is the SARIF adapter — the FIRST real consumer of the substrate's shared
|
|
5
|
+
* `ingestSarif`. So beyond the declarative surface (commandSpecs / identity /
|
|
6
|
+
* metadata), the binary helpers, the FROZEN exit model (Phase-0 decision 4: NO
|
|
7
|
+
* findings code; any nonzero is a fault), and the manifest↔runtime host-shape
|
|
8
|
+
* guards, this suite proves the SARIF READ PATH end-to-end — especially the CVSS
|
|
9
|
+
* `security-severity` SEVERITY RECOVERY:
|
|
10
|
+
*
|
|
11
|
+
* - a result with `level:"error"` + `security-severity:"9.8"` normalizes to
|
|
12
|
+
* `critical` (NOT `high` — the writer collapses critical+high → `error`, so a
|
|
13
|
+
* level-only inverse is ambiguous and the CVSS number is what disambiguates);
|
|
14
|
+
* - a result with `level:"error"` + `security-severity:"7.5"` → `high`;
|
|
15
|
+
* - a result with NO `security-severity` falls back to the `level` band
|
|
16
|
+
* (`warning` → `medium`).
|
|
17
|
+
*/
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=tool.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/tool.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG"}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier-1 (in-process) tests for the trivy adapter `Tool` (ADR-0090 D6 Tier 1).
|
|
3
|
+
*
|
|
4
|
+
* Trivy is the SARIF adapter — the FIRST real consumer of the substrate's shared
|
|
5
|
+
* `ingestSarif`. So beyond the declarative surface (commandSpecs / identity /
|
|
6
|
+
* metadata), the binary helpers, the FROZEN exit model (Phase-0 decision 4: NO
|
|
7
|
+
* findings code; any nonzero is a fault), and the manifest↔runtime host-shape
|
|
8
|
+
* guards, this suite proves the SARIF READ PATH end-to-end — especially the CVSS
|
|
9
|
+
* `security-severity` SEVERITY RECOVERY:
|
|
10
|
+
*
|
|
11
|
+
* - a result with `level:"error"` + `security-severity:"9.8"` normalizes to
|
|
12
|
+
* `critical` (NOT `high` — the writer collapses critical+high → `error`, so a
|
|
13
|
+
* level-only inverse is ambiguous and the CVSS number is what disambiguates);
|
|
14
|
+
* - a result with `level:"error"` + `security-severity:"7.5"` → `high`;
|
|
15
|
+
* - a result with NO `security-severity` falls back to the `level` band
|
|
16
|
+
* (`warning` → `medium`).
|
|
17
|
+
*/
|
|
18
|
+
import { readFileSync } from 'node:fs';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
import { assertManifestMatchesTool } from '@opensip-cli/core';
|
|
21
|
+
import { DEFAULT_EXIT_MODEL, deriveAdapterConfigManifest, deriveAdapterManifestCommands, deriveAdapterManifestRequires, ingestSarif, interpretExit, normalizedSignalShape, runAcceptanceCase, sarifLevelToSeverity, } from '@opensip-cli/external-tool-adapter';
|
|
22
|
+
import { describe, expect, it } from 'vitest';
|
|
23
|
+
import { buildScanArgs, buildTrivyExclude, parseTrivyVersion, tool, TRIVY_STABLE_ID, } from '../tool.js';
|
|
24
|
+
const PKG = JSON.parse(readFileSync(fileURLToPath(new URL('../../package.json', import.meta.url)), 'utf8'));
|
|
25
|
+
const GOLDEN_RAW = readFileSync(fileURLToPath(new URL('../../__fixtures__/trivy-golden.sarif', import.meta.url)), 'utf8');
|
|
26
|
+
const EXPECTED = JSON.parse(readFileSync(fileURLToPath(new URL('../../__fixtures__/expected-signals.json', import.meta.url)), 'utf8'));
|
|
27
|
+
/** Reconstruct the admitted `ToolPluginManifest` the host builds from package.json. */
|
|
28
|
+
function manifestFromPackage() {
|
|
29
|
+
return {
|
|
30
|
+
...PKG.opensipTools,
|
|
31
|
+
name: PKG.name,
|
|
32
|
+
version: PKG.version,
|
|
33
|
+
apiVersion: PKG.opensipTools.apiVersion,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
describe('trivy tool — identity + metadata', () => {
|
|
37
|
+
it('declares the trivy identity with NO aliases', () => {
|
|
38
|
+
expect(tool.identity).toEqual({ name: 'trivy' });
|
|
39
|
+
});
|
|
40
|
+
it('carries the stable UUID and a description', () => {
|
|
41
|
+
expect(tool.metadata.id).toBe(TRIVY_STABLE_ID);
|
|
42
|
+
expect(tool.metadata.name).toBe('trivy');
|
|
43
|
+
expect(tool.metadata.description).toBe('Vulnerability + misconfig scanning via Trivy');
|
|
44
|
+
});
|
|
45
|
+
it('defaults to the line-shift-tolerant message-hash fingerprint strategy', () => {
|
|
46
|
+
expect(tool.extensionPoints?.fingerprintStrategy?.id).toBe('external-tool-adapter.sha256-file-rule-message');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
const byName = (name) => tool.commandSpecs?.find((c) => c.name === name);
|
|
50
|
+
describe('trivy tool — commandSpecs', () => {
|
|
51
|
+
it('mounts the primary scan, plus nested doctor + version', () => {
|
|
52
|
+
const names = (tool.commandSpecs ?? []).map((c) => c.name);
|
|
53
|
+
expect(names).toEqual(['trivy', 'doctor', 'version']);
|
|
54
|
+
});
|
|
55
|
+
it('the primary command is `trivy` (no aliases), project-scoped, raw-stream dispatch', () => {
|
|
56
|
+
const primary = byName('trivy');
|
|
57
|
+
expect(primary?.parent).toBeUndefined();
|
|
58
|
+
expect(primary?.aliases).toEqual([]);
|
|
59
|
+
expect(primary?.scope).toBe('project');
|
|
60
|
+
expect(primary?.output).toBe('raw-stream');
|
|
61
|
+
expect(primary?.rawStreamReason).toBe('runtime-render-dispatch');
|
|
62
|
+
});
|
|
63
|
+
it('doctor + version are nested under trivy, scope:none, diagnostic-gate', () => {
|
|
64
|
+
for (const name of ['doctor', 'version']) {
|
|
65
|
+
const spec = byName(name);
|
|
66
|
+
expect(spec?.parent).toBe('trivy');
|
|
67
|
+
expect(spec?.scope).toBe('none');
|
|
68
|
+
expect(spec?.output).toBe('raw-stream');
|
|
69
|
+
expect(spec?.rawStreamReason).toBe('diagnostic-gate');
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('trivy tool — binary helpers', () => {
|
|
74
|
+
it('parses the trivy version stdout (banner, bare semver, or leading v)', () => {
|
|
75
|
+
expect(parseTrivyVersion('Version: 0.50.1\nVulnerability DB:\n Version: 2')).toBe('0.50.1');
|
|
76
|
+
expect(parseTrivyVersion('0.49.0\n')).toBe('0.49.0');
|
|
77
|
+
expect(parseTrivyVersion('v0.51.2')).toBe('0.51.2');
|
|
78
|
+
});
|
|
79
|
+
it('falls back to the trimmed stdout when no semver is present', () => {
|
|
80
|
+
expect(parseTrivyVersion(' unknown ')).toBe('unknown');
|
|
81
|
+
});
|
|
82
|
+
it('builds the filesystem-scan argv with the local-only flags, writing SARIF to the run artifact path', () => {
|
|
83
|
+
const ctx = {
|
|
84
|
+
projectRoot: '/proj',
|
|
85
|
+
artifactPath: (name) => `/proj/.runtime/artifacts/trivy/run1/${name}`,
|
|
86
|
+
};
|
|
87
|
+
expect(buildScanArgs(ctx)).toEqual([
|
|
88
|
+
'fs',
|
|
89
|
+
'--scanners',
|
|
90
|
+
'vuln,secret,misconfig',
|
|
91
|
+
'--format',
|
|
92
|
+
'sarif',
|
|
93
|
+
'--output',
|
|
94
|
+
'/proj/.runtime/artifacts/trivy/run1/trivy.sarif',
|
|
95
|
+
'--skip-db-update',
|
|
96
|
+
'--skip-java-db-update',
|
|
97
|
+
'--offline-scan',
|
|
98
|
+
'--skip-check-update',
|
|
99
|
+
'/proj',
|
|
100
|
+
]);
|
|
101
|
+
});
|
|
102
|
+
it('A8: requests the misconfig scanner (offline) so the advertised Dockerfile findings are actually produced', () => {
|
|
103
|
+
// `trivy fs` defaults to `vuln,secret` only — without `--scanners …,misconfig`
|
|
104
|
+
// a real run emits ZERO misconfig results while metadata/docs/the DS002 golden
|
|
105
|
+
// all advertise misconfig. The companion `--skip-check-update` keeps the
|
|
106
|
+
// misconfig checks-bundle fetch offline.
|
|
107
|
+
const ctx = {
|
|
108
|
+
projectRoot: '/proj',
|
|
109
|
+
artifactPath: (name) => `/proj/.runtime/artifacts/trivy/run1/${name}`,
|
|
110
|
+
};
|
|
111
|
+
const args = buildScanArgs(ctx);
|
|
112
|
+
const i = args.indexOf('--scanners');
|
|
113
|
+
expect(i).toBeGreaterThanOrEqual(0);
|
|
114
|
+
expect(args[i + 1]?.split(',')).toContain('misconfig');
|
|
115
|
+
expect(args).toContain('--skip-check-update');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('trivy tool — A3 .runtime exclusion (buildTrivyExclude)', () => {
|
|
119
|
+
it('skips the opensip artifact store via --skip-dirs', () => {
|
|
120
|
+
expect(buildTrivyExclude({ excludePath: '/proj/opensip-cli/.runtime' }).args).toEqual([
|
|
121
|
+
'--skip-dirs',
|
|
122
|
+
'/proj/opensip-cli/.runtime',
|
|
123
|
+
]);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('trivy tool — exit model (Phase-0 decision 4)', () => {
|
|
127
|
+
// Frozen Trivy model: Trivy exits 0 even WITH findings (no `--exit-code`), so
|
|
128
|
+
// there is NO findings code — findings are derived from the parsed SARIF and ANY
|
|
129
|
+
// nonzero exit is a genuine fault.
|
|
130
|
+
const model = { ok: [0], findings: [], errorFrom: 1 };
|
|
131
|
+
it('exit 0 ⇒ clean (findings, if any, come from the SARIF — not the exit code)', () => {
|
|
132
|
+
expect(interpretExit(0, model)).toBe('ok');
|
|
133
|
+
});
|
|
134
|
+
it('exit 1 ⇒ fault, EVEN with a valid artifact (no findings code to absorb it)', () => {
|
|
135
|
+
expect(interpretExit(1, model, { artifactValid: true })).toBe('fault');
|
|
136
|
+
});
|
|
137
|
+
it('exit 2 ⇒ fault', () => {
|
|
138
|
+
expect(interpretExit(2, model)).toBe('fault');
|
|
139
|
+
});
|
|
140
|
+
it('diverges from the substrate default by dropping the findings code', () => {
|
|
141
|
+
expect(model).not.toEqual(DEFAULT_EXIT_MODEL);
|
|
142
|
+
expect(model.findings).toEqual([]);
|
|
143
|
+
expect(model.ok).toEqual([0]);
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
describe('trivy tool — manifest ↔ runtime host-shape guards', () => {
|
|
147
|
+
it('the package.json manifest matches the runtime tool (no drift)', () => {
|
|
148
|
+
expect(() => {
|
|
149
|
+
assertManifestMatchesTool(manifestFromPackage(), tool);
|
|
150
|
+
}).not.toThrow();
|
|
151
|
+
});
|
|
152
|
+
it('the generated manifest commands equal the derived runtime command shells', () => {
|
|
153
|
+
// The package.json `commands` are written by the shared manifest generator
|
|
154
|
+
// (which OMITS an empty `aliases`); the substrate's `deriveAdapterManifestCommands`
|
|
155
|
+
// always emits `aliases: []`. Canonicalize that one representational difference
|
|
156
|
+
// (`aliases ?? []`) before comparing the substantive shells.
|
|
157
|
+
const canon = (c) => ({
|
|
158
|
+
...c,
|
|
159
|
+
aliases: c.aliases ?? [],
|
|
160
|
+
});
|
|
161
|
+
const generated = PKG.opensipTools.commands.map(canon);
|
|
162
|
+
const derived = deriveAdapterManifestCommands(tool).map((c) => canon(c));
|
|
163
|
+
expect(generated).toEqual(derived);
|
|
164
|
+
});
|
|
165
|
+
it('the generated manifest requires equal the posture-derived requires (no drift)', () => {
|
|
166
|
+
// A13: `requires` is DERIVED from the network posture, not hand-typed.
|
|
167
|
+
expect(PKG.opensipTools.requires).toEqual(deriveAdapterManifestRequires(tool));
|
|
168
|
+
});
|
|
169
|
+
it('derives subprocess + filesystem only (local-only posture, no network)', () => {
|
|
170
|
+
expect(PKG.opensipTools.requires.map((r) => r.resource)).toEqual([
|
|
171
|
+
'subprocess',
|
|
172
|
+
'filesystem',
|
|
173
|
+
]);
|
|
174
|
+
});
|
|
175
|
+
it('the generated manifest config descriptor equals the derived namespace claim (A4)', () => {
|
|
176
|
+
const derived = deriveAdapterConfigManifest(tool);
|
|
177
|
+
expect(derived?.namespace).toBe('trivy');
|
|
178
|
+
expect(PKG.opensipTools.config).toEqual(derived);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
describe('trivy tool — shared ingestSarif (normalize → envelope)', () => {
|
|
182
|
+
const result = runAcceptanceCase({
|
|
183
|
+
tool: 'trivy',
|
|
184
|
+
kind: 'sarif',
|
|
185
|
+
raw: GOLDEN_RAW,
|
|
186
|
+
fingerprintStrategy: 'message-hash',
|
|
187
|
+
});
|
|
188
|
+
it('produces the golden normalized signals via the shared SARIF read path', () => {
|
|
189
|
+
expect(result.signals.map(normalizedSignalShape)).toEqual(EXPECTED);
|
|
190
|
+
});
|
|
191
|
+
it('builds an envelope whose verdict FAILS (critical + high are error-rung)', () => {
|
|
192
|
+
expect(result.envelope.tool).toBe('trivy');
|
|
193
|
+
expect(result.envelope.verdict.passed).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
it('stamps a message-hash fingerprint on every envelope signal worker-side', () => {
|
|
196
|
+
expect(result.envelope.signals).toHaveLength(3);
|
|
197
|
+
for (const s of result.envelope.signals) {
|
|
198
|
+
expect(s.fingerprint).toMatch(/^[0-9a-f]{64}$/);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe('trivy tool — SARIF severity recovery (the ingest core job, ADR-0091 D2)', () => {
|
|
203
|
+
const signals = ingestSarif(JSON.parse(GOLDEN_RAW), { source: 'trivy' });
|
|
204
|
+
const byRule = (id) => signals.find((s) => s.ruleId === id);
|
|
205
|
+
it('recovers `critical` from CVSS 9.8 even though `level:"error"` alone maps to `high`', () => {
|
|
206
|
+
// The load-bearing proof: the SARIF `level` is lossy (critical AND high → error),
|
|
207
|
+
// so a level-only inverse can never reach critical.
|
|
208
|
+
expect(sarifLevelToSeverity('error')).toBe('high');
|
|
209
|
+
const certifi = byRule('CVE-2023-37920');
|
|
210
|
+
expect(certifi?.severity).toBe('critical');
|
|
211
|
+
expect(certifi?.metadata.securitySeverity).toBe('9.8');
|
|
212
|
+
expect(certifi?.metadata.nativeLevel).toBe('error');
|
|
213
|
+
});
|
|
214
|
+
it('recovers `high` from CVSS 7.5 (a second `level:"error"` result, distinct band)', () => {
|
|
215
|
+
const setuptools = byRule('CVE-2022-40897');
|
|
216
|
+
expect(setuptools?.severity).toBe('high');
|
|
217
|
+
expect(setuptools?.metadata.securitySeverity).toBe('7.5');
|
|
218
|
+
expect(setuptools?.metadata.nativeLevel).toBe('error');
|
|
219
|
+
});
|
|
220
|
+
it('falls back to the `level` band when a rule has NO security-severity (warning → medium)', () => {
|
|
221
|
+
const misconfig = byRule('DS002');
|
|
222
|
+
expect(misconfig?.severity).toBe('medium');
|
|
223
|
+
// No CVSS number was present → no securitySeverity recovered; the native level
|
|
224
|
+
// is preserved for provenance.
|
|
225
|
+
expect(misconfig?.metadata.securitySeverity).toBeUndefined();
|
|
226
|
+
expect(misconfig?.metadata.nativeLevel).toBe('warning');
|
|
227
|
+
});
|
|
228
|
+
it('anchors each finding at its lockfile/Dockerfile location (startLine 1)', () => {
|
|
229
|
+
expect(byRule('CVE-2023-37920')?.filePath).toBe('requirements.txt');
|
|
230
|
+
expect(byRule('CVE-2023-37920')?.line).toBe(1);
|
|
231
|
+
expect(byRule('DS002')?.filePath).toBe('Dockerfile');
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
//# sourceMappingURL=tool.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool.test.js","sourceRoot":"","sources":["../../src/__tests__/tool.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,2BAA2B,EAC3B,6BAA6B,EAC7B,6BAA6B,EAC7B,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EAC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
|
+
* Trivy is the SARIF adapter, so this also proves the shared `ingestSarif` read
|
|
6
|
+
* path through the FULL installed-tool dispatch:
|
|
7
|
+
* - the trivy package is presented as a genuinely INSTALLED npm tool in a
|
|
8
|
+
* throwaway project (symlinked into its `node_modules` so the worker resolves
|
|
9
|
+
* the adapter's workspace deps from the monorepo via realpath);
|
|
10
|
+
* - `OPENSIP_CLI_ALLOW_INSTALLED_TOOLS` trusts it (installed tools are
|
|
11
|
+
* deny-by-default);
|
|
12
|
+
* - a FAKE `trivy` binary on PATH makes the run deterministic: it copies the
|
|
13
|
+
* committed golden SARIF to `--output` and exits 0 — Trivy exits 0 EVEN WITH
|
|
14
|
+
* findings, so the CLI's nonzero exit comes from the findings DERIVED FROM THE
|
|
15
|
+
* PARSED SARIF, not from the process exit (the Trivy exit-model proof). The
|
|
16
|
+
* worker fork curates its env to an allow-list, so the golden path is forwarded
|
|
17
|
+
* via the documented `OPENSIP_CLI_TOOL_ENV_PASSTHROUGH`.
|
|
18
|
+
*
|
|
19
|
+
* `opensip trivy` forks a worker that re-discovers + imports the real runtime and
|
|
20
|
+
* runs the scan loop; this suite asserts the worker→host result + host-side
|
|
21
|
+
* effects: normalized signals match the golden (with the RECOVERED severities —
|
|
22
|
+
* `critical` from CVSS 9.8, not `high` from `level:"error"`), the raw SARIF
|
|
23
|
+
* artifact lands at `.runtime/artifacts/trivy/<runId>/trivy.sarif` with mode 0600,
|
|
24
|
+
* the `--json` envelope is well-formed, the session row persists with provenance,
|
|
25
|
+
* and the full gate ratchet (gate-save → clean compare → net-new vuln surfaces)
|
|
26
|
+
* works.
|
|
27
|
+
*
|
|
28
|
+
* Requires `pnpm build` first (the CLI dist + the trivy dist). Missing builds FAIL
|
|
29
|
+
* loudly (no silent skip).
|
|
30
|
+
*/
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=worker-e2e.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-e2e.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/worker-e2e.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG"}
|