Skip to content

Commit 85c4d47

Browse files
committed
feat: Show secret_vaulted in results
1 parent 3fec294 commit 85c4d47

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

src/lib/api-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export interface Incident {
2424
known_secret: boolean;
2525
incident_url: string;
2626
total_occurrences: number;
27+
secret_vaulted: boolean;
2728
}
2829

2930
export interface EntityWithIncidents {

src/lib/ggshield-results-parser.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const validityDisplayName: Record<Validity, string> = {
3434
*/
3535
function filterUriOccurrences(occurrences: Occurrence[]): Occurrence[] {
3636
const uriOccurrence = occurrences.find(
37-
({ type }) => type === "connection_uri"
37+
({ type }) => type === "connection_uri",
3838
);
3939
return uriOccurrence ? [uriOccurrence] : occurrences;
4040
}
@@ -46,7 +46,7 @@ function filterUriOccurrences(occurrences: Occurrence[]): Occurrence[] {
4646
* @returns incidents diagnostics
4747
*/
4848
export function parseGGShieldResults(
49-
results: GGShieldScanResults
49+
results: GGShieldScanResults,
5050
): Diagnostic[] {
5151
let diagnostics: Diagnostic[] = [];
5252

@@ -61,7 +61,7 @@ export function parseGGShieldResults(
6161
(occurrence: Occurrence) => {
6262
let range = new Range(
6363
new Position(occurrence.line_start - 1, occurrence.index_start),
64-
new Position(occurrence.line_end - 1, occurrence.index_end)
64+
new Position(occurrence.line_end - 1, occurrence.index_end),
6565
);
6666
let diagnostic = new Diagnostic(
6767
range,
@@ -72,16 +72,17 @@ Validity: ${validityDisplayName[incident.validity]}
7272
Known by GitGuardian dashboard: ${incident.known_secret ? "YES" : "NO"}
7373
Total occurrences: ${incident.total_occurrences}
7474
Incident URL: ${incident.incident_url || "N/A"}
75-
Secret SHA: ${incident.ignore_sha}`,
76-
DiagnosticSeverity.Warning
75+
Secret SHA: ${incident.ignore_sha}
76+
Secret in Secrets Manager: ${incident.secret_vaulted ? "YES" : "NO"}`,
77+
DiagnosticSeverity.Warning,
7778
);
7879

7980
diagnostic.source = "gitguardian";
8081
diagnostics.push(diagnostic);
81-
}
82+
},
8283
);
8384
});
84-
}
85+
},
8586
);
8687
} catch (e) {
8788
console.error(e);

src/test/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export const scanResultsWithIncident = `{
2828
"ignore_sha":"38353eb1a2aac5b24f39ed67912234d4b4a2e23976d504a88b28137ed2b9185e",
2929
"total_occurrences":1,
3030
"incident_url":"",
31-
"known_secret":false
31+
"known_secret":false,
32+
"secret_vaulted": false
3233
}
3334
],
3435
"total_incidents":1,

src/test/suite/results-parser.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ import {
1111
suite("parseGGShieldResults", () => {
1212
test("Should parse ggshield scan output", () => {
1313
const diagnostics = parseGGShieldResults(
14-
JSON.parse(scanResultsWithIncident)
14+
JSON.parse(scanResultsWithIncident),
1515
);
1616
assert.strictEqual(diagnostics.length, 1);
1717
const diagnostic = diagnostics[0];
1818
assert.ok(diagnostic.message.includes("apikey"));
1919
assert.ok(diagnostic.message.includes("Generic High Entropy Secret"));
20+
assert.ok(diagnostic.message.includes("Secret in Secrets Manager: NO"));
2021
assert.strictEqual(diagnostic.range.start.line, 3);
2122
assert.strictEqual(diagnostic.range.start.character, 11);
2223
assert.strictEqual(diagnostic.range.end.line, 3);
@@ -36,7 +37,7 @@ suite("parseGGShieldResults", () => {
3637

3738
test("Should only return the 'connection_uri' match if the secret is an URI", () => {
3839
const diagnostics = parseGGShieldResults(
39-
JSON.parse(scanResultsWithUriIncident)
40+
JSON.parse(scanResultsWithUriIncident),
4041
);
4142
assert.strictEqual(diagnostics.length, 1);
4243
assert.ok(diagnostics[0].message.includes("connection_uri"));

0 commit comments

Comments
 (0)