Skip to content

Commit 98ec90f

Browse files
committed
adding check for AI guided remediation enabled on tenant
1 parent b4ce733 commit 98ec90f

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/main/wrapper/CxConstants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@ export enum CxConstants {
9393
SEVERITY_MEDIUM = "medium",
9494
STATE_CONFIRMED = "confirmed",
9595
CMD_LEARN_MORE = "learn-more",
96-
IDE_SCANS_KEY = " scan.config.plugins.ideScans"
96+
IDE_SCANS_KEY = " scan.config.plugins.ideScans",
97+
AI_GUIDED_REMEDIATION_KEY = " scan.config.plugins.aiGuidedRemediation"
9798
}

src/main/wrapper/CxWrapper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,14 @@ export class CxWrapper {
299299
return output.has(CxConstants.IDE_SCANS_KEY) && output.get(CxConstants.IDE_SCANS_KEY).toLowerCase() === " true";
300300
}
301301

302+
async guidedRemediationEnabled() : Promise<boolean> {
303+
const commands: string[] = [CxConstants.CMD_UTILS, CxConstants.SUB_CMD_TENANT];
304+
commands.push(...this.initializeCommands(false));
305+
const exec = new ExecutionService();
306+
const output = await exec.executeMapTenantOutputCommands(this.config.pathToExecutable, commands);
307+
return output.has(CxConstants.AI_GUIDED_REMEDIATION_KEY) && output.get(CxConstants.AI_GUIDED_REMEDIATION_KEY).toLowerCase() === " true";
308+
}
309+
302310
async chat(apikey: string, file: string, line: number, severity: string, vulnerability: string, input: string, conversationId?: string, model?: string): Promise<CxCommandOutput> {
303311
const commands: string[] = [
304312
CxConstants.CMD_CHAT,

src/tests/ScanTest.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,17 @@ describe("ScanCreate cases", () => {
112112
})
113113

114114
it("Should check if scan create is possible", async() => {
115+
const cxScanConfig = new BaseTest();
115116
const auth = new CxWrapper(cxScanConfig);
116117
const tenantSettings: boolean = await auth.ideScansEnabled();
117118
expect(tenantSettings).toBeDefined();
118119
})
120+
121+
it("Should check if AI guided remediation is active", async() => {
122+
const cxScanConfig = new BaseTest();
123+
const auth = new CxWrapper(cxScanConfig);
124+
const aiEnabled: boolean = await auth.guidedRemediationEnabled();
125+
expect(aiEnabled).toBeDefined();
126+
})
127+
119128
});

0 commit comments

Comments
 (0)