Skip to content

Commit 7a1daa3

Browse files
committed
feat(ggshield-configuration): Add optional 'allow self signed' option for certificates
1 parent 96a9412 commit 7a1daa3

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"type": "string",
3535
"default": "",
3636
"markdownDescription": "Your API Key"
37+
},
38+
"gitguardian.allowSelfSigned": {
39+
"type": "boolean",
40+
"default": false,
41+
"markdownDescription": "Allow Self Signed Certificates"
3742
}
3843
}
3944
},

src/lib/ggshield-configuration.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ export class GGShieldConfiguration {
88
ggshieldPath: string;
99
apiUrl: string;
1010
apiKey: string;
11+
allowSelfSigned: boolean;
1112

1213
constructor(
1314
ggshieldPath: string = "",
1415
apiUrl: string = "",
15-
apiKey: string = ""
16+
apiKey: string = "",
17+
allowSelfSigned: boolean = false
1618
) {
1719
this.ggshieldPath = ggshieldPath;
1820
this.apiUrl = apiUrl;
1921
this.apiKey = apiKey;
22+
this.allowSelfSigned = allowSelfSigned;
2023
}
2124
}
2225

@@ -34,13 +37,15 @@ export function getConfiguration(
3437
const ggshieldPath: string | undefined = config.get("GGShieldPath");
3538
const apiUrl: string | undefined = config.get("apiUrl");
3639
const apiKey: string | undefined = config.get("apiKey");
40+
const allowSelfSigned: boolean = config.get("allowSelfSigned", false);
3741

3842
return new GGShieldConfiguration(
3943
ggshieldPath
4044
? ggshieldPath
4145
: getBinaryAbsolutePath(os.platform(), os.arch(), context),
4246
apiUrl ? apiUrl : apiUrlDefault,
43-
apiKey ? apiKey : ""
47+
apiKey ? apiKey : "",
48+
allowSelfSigned ? allowSelfSigned : false
4449
);
4550
}
4651

src/lib/run-ggshield.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ export function runGGShieldCommand(
4141
if (workspace.workspaceFolders?.length || 0 > 0) {
4242
options["cwd"] = workspace.workspaceFolders![0].uri.fsPath;
4343
}
44+
// if allowSelfSigned is enabled, add the --allow-self-signed flag
45+
if (configuration.allowSelfSigned) {
46+
args = ["--allow-self-signed"].concat(args);
47+
}
4448
let proc = spawnSync(ggshieldPath, args, options);
4549

4650
return proc;

0 commit comments

Comments
 (0)