securewithtrace 0.21.6 → 0.22.0
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/dist/index.js +119 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -24600,6 +24600,15 @@ var ScanMode2 = external_exports.enum(ScanModeValues2);
|
|
|
24600
24600
|
var VulnerabilityIdParamsSchema = OrgIdParamsSchema.extend({
|
|
24601
24601
|
vulnerabilityId: external_exports.uuid()
|
|
24602
24602
|
});
|
|
24603
|
+
var VulnerabilityLookupIdSchema = external_exports.union([
|
|
24604
|
+
external_exports.uuid(),
|
|
24605
|
+
external_exports.string().regex(/^(?:TRACE-)?0*[1-9]\d*$/i, {
|
|
24606
|
+
message: "vulnerabilityId must be a UUID, a positive integer, or TRACE-<number>"
|
|
24607
|
+
})
|
|
24608
|
+
]);
|
|
24609
|
+
var VulnerabilityLookupIdParamsSchema = OrgIdParamsSchema.extend({
|
|
24610
|
+
vulnerabilityId: VulnerabilityLookupIdSchema
|
|
24611
|
+
});
|
|
24603
24612
|
var VulnerabilitySourceSchema = external_exports.object({
|
|
24604
24613
|
branch: external_exports.string().nullable(),
|
|
24605
24614
|
commitSha: external_exports.string().nullable(),
|
|
@@ -24802,9 +24811,10 @@ var vulnerabilityContract = c17.router({
|
|
|
24802
24811
|
getVulnerability: {
|
|
24803
24812
|
method: "GET",
|
|
24804
24813
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId",
|
|
24805
|
-
pathParams:
|
|
24814
|
+
pathParams: VulnerabilityLookupIdParamsSchema,
|
|
24806
24815
|
responses: {
|
|
24807
24816
|
200: VulnerabilityResponseSchema,
|
|
24817
|
+
400: ErrorResponseSchema,
|
|
24808
24818
|
401: ErrorResponseSchema,
|
|
24809
24819
|
403: ErrorResponseSchema,
|
|
24810
24820
|
404: ErrorResponseSchema,
|
|
@@ -24814,7 +24824,7 @@ var vulnerabilityContract = c17.router({
|
|
|
24814
24824
|
updateVulnerability: {
|
|
24815
24825
|
method: "PATCH",
|
|
24816
24826
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId",
|
|
24817
|
-
pathParams:
|
|
24827
|
+
pathParams: VulnerabilityLookupIdParamsSchema,
|
|
24818
24828
|
body: UpdateVulnerabilityRequestSchema,
|
|
24819
24829
|
responses: {
|
|
24820
24830
|
200: VulnerabilityResponseSchema,
|
|
@@ -24842,7 +24852,7 @@ var vulnerabilityContract = c17.router({
|
|
|
24842
24852
|
deleteVulnerability: {
|
|
24843
24853
|
method: "DELETE",
|
|
24844
24854
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId",
|
|
24845
|
-
pathParams:
|
|
24855
|
+
pathParams: VulnerabilityLookupIdParamsSchema,
|
|
24846
24856
|
responses: {
|
|
24847
24857
|
204: DeleteResponseSchema,
|
|
24848
24858
|
401: ErrorResponseSchema,
|
|
@@ -24854,7 +24864,7 @@ var vulnerabilityContract = c17.router({
|
|
|
24854
24864
|
retestVulnerability: {
|
|
24855
24865
|
method: "POST",
|
|
24856
24866
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/retest",
|
|
24857
|
-
pathParams:
|
|
24867
|
+
pathParams: VulnerabilityLookupIdParamsSchema,
|
|
24858
24868
|
body: null,
|
|
24859
24869
|
responses: {
|
|
24860
24870
|
201: ScanResponseSchema,
|
|
@@ -24881,7 +24891,7 @@ var vulnerabilityContract = c17.router({
|
|
|
24881
24891
|
getVulnerabilityRetests: {
|
|
24882
24892
|
method: "GET",
|
|
24883
24893
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/retests",
|
|
24884
|
-
pathParams:
|
|
24894
|
+
pathParams: VulnerabilityLookupIdParamsSchema,
|
|
24885
24895
|
responses: {
|
|
24886
24896
|
200: ScanArrayResponseSchema,
|
|
24887
24897
|
401: ErrorResponseSchema,
|
|
@@ -24893,10 +24903,10 @@ var vulnerabilityContract = c17.router({
|
|
|
24893
24903
|
});
|
|
24894
24904
|
|
|
24895
24905
|
// ../../packages/api-contracts/src/schemas/api/v1/vulnerability-note.api.ts
|
|
24896
|
-
var
|
|
24897
|
-
vulnerabilityId:
|
|
24906
|
+
var VulnerabilityLookupNoteParamsSchema = OrgIdParamsSchema.extend({
|
|
24907
|
+
vulnerabilityId: VulnerabilityLookupIdSchema
|
|
24898
24908
|
});
|
|
24899
|
-
var
|
|
24909
|
+
var VulnerabilityLookupNoteIdParamsSchema = VulnerabilityLookupNoteParamsSchema.extend({
|
|
24900
24910
|
noteId: external_exports.uuid()
|
|
24901
24911
|
});
|
|
24902
24912
|
var VulnerabilityNoteResponseSchema = external_exports.object({
|
|
@@ -24924,9 +24934,10 @@ var vulnerabilityNoteContract = c18.router({
|
|
|
24924
24934
|
listNotes: {
|
|
24925
24935
|
method: "GET",
|
|
24926
24936
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/notes",
|
|
24927
|
-
pathParams:
|
|
24937
|
+
pathParams: VulnerabilityLookupNoteParamsSchema,
|
|
24928
24938
|
responses: {
|
|
24929
24939
|
200: ListVulnerabilityNotesResponseSchema,
|
|
24940
|
+
400: ErrorResponseSchema,
|
|
24930
24941
|
401: ErrorResponseSchema,
|
|
24931
24942
|
403: ErrorResponseSchema,
|
|
24932
24943
|
404: ErrorResponseSchema,
|
|
@@ -24936,7 +24947,7 @@ var vulnerabilityNoteContract = c18.router({
|
|
|
24936
24947
|
createNote: {
|
|
24937
24948
|
method: "POST",
|
|
24938
24949
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/notes",
|
|
24939
|
-
pathParams:
|
|
24950
|
+
pathParams: VulnerabilityLookupNoteParamsSchema,
|
|
24940
24951
|
body: CreateVulnerabilityNoteRequestSchema,
|
|
24941
24952
|
responses: {
|
|
24942
24953
|
201: VulnerabilityNoteResponseSchema,
|
|
@@ -24950,7 +24961,7 @@ var vulnerabilityNoteContract = c18.router({
|
|
|
24950
24961
|
updateNote: {
|
|
24951
24962
|
method: "PATCH",
|
|
24952
24963
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/notes/:noteId",
|
|
24953
|
-
pathParams:
|
|
24964
|
+
pathParams: VulnerabilityLookupNoteIdParamsSchema,
|
|
24954
24965
|
body: UpdateVulnerabilityNoteRequestSchema,
|
|
24955
24966
|
responses: {
|
|
24956
24967
|
200: VulnerabilityNoteResponseSchema,
|
|
@@ -24964,9 +24975,10 @@ var vulnerabilityNoteContract = c18.router({
|
|
|
24964
24975
|
deleteNote: {
|
|
24965
24976
|
method: "DELETE",
|
|
24966
24977
|
path: "/organizations/:organizationId/vulnerabilities/:vulnerabilityId/notes/:noteId",
|
|
24967
|
-
pathParams:
|
|
24978
|
+
pathParams: VulnerabilityLookupNoteIdParamsSchema,
|
|
24968
24979
|
responses: {
|
|
24969
24980
|
204: DeleteResponseSchema,
|
|
24981
|
+
400: ErrorResponseSchema,
|
|
24970
24982
|
401: ErrorResponseSchema,
|
|
24971
24983
|
403: ErrorResponseSchema,
|
|
24972
24984
|
404: ErrorResponseSchema,
|
|
@@ -29119,6 +29131,100 @@ function printVulnerabilitiesTsv(vulnerabilities) {
|
|
|
29119
29131
|
console.log(cols.join(" "));
|
|
29120
29132
|
}
|
|
29121
29133
|
}
|
|
29134
|
+
function printVulnerabilityDetail(vulnerability) {
|
|
29135
|
+
const severity = colorSeverity(vulnerability.severity, formatSeverity(vulnerability.severity));
|
|
29136
|
+
const status = formatStatus(vulnerability.status);
|
|
29137
|
+
const metadata = [
|
|
29138
|
+
`Type: ${vulnerability.vulnerabilityType}`,
|
|
29139
|
+
vulnerability.scanMode ? `Scan mode: ${vulnerability.scanMode}` : null,
|
|
29140
|
+
vulnerability.cweId ? vulnerability.cweId : null
|
|
29141
|
+
].filter((value) => value !== null);
|
|
29142
|
+
const sourceDetails = [
|
|
29143
|
+
vulnerability.source.branch ? `Branch: ${vulnerability.source.branch}` : null,
|
|
29144
|
+
vulnerability.source.pullRequestNumber !== null ? `PR #${vulnerability.source.pullRequestNumber}${vulnerability.source.pullRequestTitle ? ` (${vulnerability.source.pullRequestTitle})` : ""}` : null
|
|
29145
|
+
].filter((value) => value !== null);
|
|
29146
|
+
console.log(` [${severity}] ${vulnerability.traceId} ${vulnerability.title}`);
|
|
29147
|
+
console.log(
|
|
29148
|
+
` ${vulnerability.repositoryName} \xB7 ${vulnerability.codeSnippet.filePath}:${vulnerability.codeSnippet.startLine} \xB7 ${status}`
|
|
29149
|
+
);
|
|
29150
|
+
if (metadata.length > 0) {
|
|
29151
|
+
console.log(` ${metadata.join(" | ")}`);
|
|
29152
|
+
}
|
|
29153
|
+
if (sourceDetails.length > 0) {
|
|
29154
|
+
console.log(` ${sourceDetails.join(" | ")}`);
|
|
29155
|
+
}
|
|
29156
|
+
console.log(` Vulnerability ID: ${vulnerability.vulnerabilityId}`);
|
|
29157
|
+
console.log("");
|
|
29158
|
+
console.log(vulnerability.description);
|
|
29159
|
+
}
|
|
29160
|
+
function printVulnerabilityDetailTsv(vulnerability) {
|
|
29161
|
+
console.log(
|
|
29162
|
+
"traceId vulnerabilityId severity status repository file line cweId scanMode title description"
|
|
29163
|
+
);
|
|
29164
|
+
const cols = [
|
|
29165
|
+
vulnerability.traceId,
|
|
29166
|
+
vulnerability.vulnerabilityId,
|
|
29167
|
+
vulnerability.severity,
|
|
29168
|
+
vulnerability.status,
|
|
29169
|
+
vulnerability.repositoryName,
|
|
29170
|
+
vulnerability.codeSnippet.filePath,
|
|
29171
|
+
String(vulnerability.codeSnippet.startLine),
|
|
29172
|
+
vulnerability.cweId ?? "",
|
|
29173
|
+
vulnerability.scanMode ?? "",
|
|
29174
|
+
vulnerability.title,
|
|
29175
|
+
vulnerability.description
|
|
29176
|
+
].map(sanitizeTsvField);
|
|
29177
|
+
console.log(cols.join(" "));
|
|
29178
|
+
}
|
|
29179
|
+
function createGetCommand() {
|
|
29180
|
+
return new Command("get").description("Get a vulnerability by display ID or UUID").argument("<id>", "Vulnerability display ID (e.g. TRACE-123 or 123) or UUID").option("-o, --output <format>", "Output format: table, json, tsv (default: table)", "table").addHelpText(
|
|
29181
|
+
"after",
|
|
29182
|
+
`
|
|
29183
|
+
Examples:
|
|
29184
|
+
tracecli vulnerabilities get TRACE-123
|
|
29185
|
+
tracecli vulnerabilities get 123
|
|
29186
|
+
tracecli vulnerabilities get 00000000-0000-4000-8000-000000000123
|
|
29187
|
+
tracecli vulnerabilities get TRACE-123 --output json
|
|
29188
|
+
tracecli vulnerabilities get TRACE-123 --output tsv`
|
|
29189
|
+
).action(async (identifier, options) => {
|
|
29190
|
+
const organizationId = await resolveOrganizationId();
|
|
29191
|
+
const result = await authenticatedRequest(
|
|
29192
|
+
(client) => client.vulnerability.getVulnerability({
|
|
29193
|
+
params: { organizationId, vulnerabilityId: identifier }
|
|
29194
|
+
})
|
|
29195
|
+
);
|
|
29196
|
+
if (result.status === 401) {
|
|
29197
|
+
console.error("Authentication failed. Run `tracecli auth login` to re-authenticate.");
|
|
29198
|
+
process.exit(1);
|
|
29199
|
+
}
|
|
29200
|
+
if (result.status === 400) {
|
|
29201
|
+
console.error(
|
|
29202
|
+
`Invalid vulnerability identifier '${identifier}'. Use TRACE-<number>, a positive integer, or a UUID.`
|
|
29203
|
+
);
|
|
29204
|
+
process.exit(1);
|
|
29205
|
+
}
|
|
29206
|
+
if (result.status === 404) {
|
|
29207
|
+
console.error(
|
|
29208
|
+
`Vulnerability '${identifier}' not found.
|
|
29209
|
+
Run \`tracecli vulnerabilities list\` to see available vulnerabilities.`
|
|
29210
|
+
);
|
|
29211
|
+
process.exit(1);
|
|
29212
|
+
}
|
|
29213
|
+
if (result.status !== 200) {
|
|
29214
|
+
console.error(`Failed to fetch vulnerability (status ${result.status}).`);
|
|
29215
|
+
process.exit(1);
|
|
29216
|
+
}
|
|
29217
|
+
if (options.output === "json") {
|
|
29218
|
+
console.log(JSON.stringify(result.body, null, 2));
|
|
29219
|
+
return;
|
|
29220
|
+
}
|
|
29221
|
+
if (options.output === "tsv") {
|
|
29222
|
+
printVulnerabilityDetailTsv(result.body);
|
|
29223
|
+
return;
|
|
29224
|
+
}
|
|
29225
|
+
printVulnerabilityDetail(result.body);
|
|
29226
|
+
});
|
|
29227
|
+
}
|
|
29122
29228
|
function createListCommand3() {
|
|
29123
29229
|
return new Command("list").description("List vulnerabilities for your organization").option("--repo <repo>", "Filter by repository name or owner/repo").option(
|
|
29124
29230
|
"--severity <severity>",
|
|
@@ -29246,6 +29352,7 @@ Examples:
|
|
|
29246
29352
|
}
|
|
29247
29353
|
function createVulnerabilitiesCommand() {
|
|
29248
29354
|
const vulnerabilities = new Command("vulnerabilities").description("Manage vulnerabilities");
|
|
29355
|
+
vulnerabilities.addCommand(createGetCommand());
|
|
29249
29356
|
vulnerabilities.addCommand(createListCommand3());
|
|
29250
29357
|
return vulnerabilities;
|
|
29251
29358
|
}
|