Skip to content

Commit bd0367a

Browse files
committed
fix: rename GGShieldConfiguration.allowSelfSigned to insecure
1 parent 6be7c88 commit bd0367a

File tree

5 files changed

+20
-26
lines changed

5 files changed

+20
-26
lines changed

src/lib/ggshield-configuration.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export class GGShieldConfiguration {
22
ggshieldPath: string;
33
apiUrl: string;
4-
allowSelfSigned: boolean;
4+
insecure: boolean;
55

66
constructor(
77
ggshieldPath: string = "",
88
apiUrl: string = "",
9-
allowSelfSigned: boolean = false,
9+
insecure: boolean = false,
1010
) {
1111
this.ggshieldPath = ggshieldPath;
1212
this.apiUrl = apiUrl;
13-
this.allowSelfSigned = allowSelfSigned;
13+
this.insecure = insecure;
1414
}
1515
}

src/lib/ggshield-resolver-utils.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function getGGShield(
3636
arch: string,
3737
context: ExtensionContext,
3838
outputChannel: OutputChannel,
39-
allowSelfSigned: boolean,
39+
insecure: boolean,
4040
): Promise<string> {
4141
const version = getGGShieldVersion(context);
4242
console.log(`Latest GGShield version: ${version}`);
@@ -65,13 +65,7 @@ export async function getGGShield(
6565
}
6666
fs.mkdirSync(ggshieldFolder);
6767
// install GGShield
68-
await installGGShield(
69-
platform,
70-
arch,
71-
ggshieldFolder,
72-
version,
73-
allowSelfSigned,
74-
);
68+
await installGGShield(platform, arch, ggshieldFolder, version, insecure);
7569
outputChannel.appendLine(
7670
`Updated to GGShield v${version}. Checkout https://github.com/GitGuardian/ggshield for more info.`,
7771
);
@@ -138,7 +132,7 @@ export async function installGGShield(
138132
arch: string,
139133
ggshieldFolder: string,
140134
version: string,
141-
allowSelfSigned: boolean,
135+
insecure: boolean,
142136
): Promise<void> {
143137
let extension: string = "";
144138
switch (platform) {
@@ -163,7 +157,7 @@ export async function installGGShield(
163157
fileName,
164158
downloadUrl,
165159
ggshieldFolder,
166-
allowSelfSigned,
160+
insecure,
167161
);
168162
extractGGShieldBinary(path.join(ggshieldFolder, fileName), ggshieldFolder);
169163
}
@@ -201,11 +195,11 @@ async function downloadGGShieldFromGitHub(
201195
fileName: string,
202196
downloadUrl: string,
203197
ggshieldFolder: string,
204-
allowSelfSigned: boolean,
198+
insecure: boolean,
205199
): Promise<void> {
206200
console.log(`Downloading GGShield from ${downloadUrl}`);
207201

208-
const instance = allowSelfSigned
202+
const instance = insecure
209203
? new Agent({
210204
rejectUnauthorized: false,
211205
})

src/lib/run-ggshield.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export function runGGShieldCommand(
3737
if (workspace.workspaceFolders?.length || 0 > 0) {
3838
options["cwd"] = workspace.workspaceFolders![0].uri.fsPath;
3939
}
40-
// if allowSelfSigned is enabled, add the --allow-self-signed flag
41-
if (configuration.allowSelfSigned) {
40+
// if insecure is enabled, add the --allow-self-signed flag
41+
if (configuration.insecure) {
4242
args = ["--allow-self-signed"].concat(args);
4343
}
4444

src/test/suite/lib/ggshield-configuration-utils.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ suite("getConfiguration", () => {
5252

5353
// Assert that the configuration has the expected values
5454
assert.strictEqual(configuration.apiUrl, "https://custom-url.com");
55-
assert.strictEqual(configuration.allowSelfSigned, true);
55+
assert.strictEqual(configuration.insecure, true);
5656
});
5757
});

src/test/suite/lib/run-ggshield.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,28 @@ suite("runGGShieldCommand", () => {
3636
delete process.env.TEST_GLOBAL_VAR;
3737
});
3838

39-
const testCasesAllowSelfSigned = [
39+
const testCasesInsecure = [
4040
{
41-
allowSelfSigned: true,
41+
insecure: true,
4242
description:
43-
"GGshield is called with flag --allow-self-signed when allowSelfSigned is true",
43+
"GGshield is called with flag --allow-self-signed when insecure is true",
4444
},
4545
{
46-
allowSelfSigned: false,
46+
insecure: false,
4747
description:
48-
"GGshield is not called with flag --allow-self-signed when allowSelfSigned is false",
48+
"GGshield is not called with flag --allow-self-signed when insecure is false",
4949
},
5050
];
5151

52-
testCasesAllowSelfSigned.forEach(({ allowSelfSigned, description }) => {
52+
testCasesInsecure.forEach(({ insecure: insecure, description }) => {
5353
test(description, () => {
5454
process.env.TEST_GLOBAL_VAR = "GlobalValue";
5555

5656
runGGShield.runGGShieldCommand(
5757
{
5858
ggshieldPath: "path/to/ggshield",
5959
apiUrl: "",
60-
allowSelfSigned: allowSelfSigned,
60+
insecure: insecure,
6161
} as GGShieldConfiguration,
6262
["test"],
6363
);
@@ -67,7 +67,7 @@ suite("runGGShieldCommand", () => {
6767
const spawnSyncArgs = spawnSyncMock.lastCall.args;
6868
const args = spawnSyncArgs[1];
6969

70-
assert.strictEqual(args[0] === "--allow-self-signed", allowSelfSigned);
70+
assert.strictEqual(args[0] === "--allow-self-signed", insecure);
7171
});
7272
});
7373

0 commit comments

Comments
 (0)