Skip to content

Js Wrappers | Sync Wrapper to Runtime Wrapper (AST-69474) #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 139 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
3032649
Update checkmarx-ast-cli.version (#763)
cx-ben-alvo Sep 23, 2024
ed9e9ae
Update Vorpal Name to ASCA(AST-65647) (#759)
cx-miryam-foifer Sep 23, 2024
92e48ee
[create-pull-request] automated change (#764)
OrShamirCM Sep 23, 2024
434fbfe
Update checkmarx-ast-cli binaries with 2.3.0 (#766)
cx-pedro-lopes Oct 8, 2024
8ad519d
[create-pull-request] automated change (#771)
OrShamirCM Oct 8, 2024
c6981d2
Update checkmarx-ast-cli binaries with 2.3.1 (#773)
cx-pedro-lopes Oct 21, 2024
01d2099
[create-pull-request] automated change (#774)
OrShamirCM Oct 21, 2024
ee9da85
Update checkmarx-ast-cli binaries with 2.3.3 (#776)
cx-pedro-lopes Nov 4, 2024
8870716
[create-pull-request] automated change (#779)
OrShamirCM Nov 4, 2024
eda3bf6
Update Node version ( AST-72890) (#780)
cx-sarah-chen Nov 11, 2024
07bf2bf
Add AST Scan (#783)
amacedoo Nov 11, 2024
446b514
Update checkmarx-ast-cli binaries with 2.3.5 (#784)
cx-pedro-lopes Nov 18, 2024
ed28b72
[create-pull-request] automated change (#785)
OrShamirCM Nov 18, 2024
8636201
delete git lfs
BenAlvo1 Sep 17, 2024
dbde9c1
check
BenAlvo1 Sep 17, 2024
5d21bac
implement CxInstaller.ts
BenAlvo1 Sep 18, 2024
f18cbe2
implement CxInstaller
BenAlvo1 Sep 18, 2024
70896df
check linter
BenAlvo1 Sep 18, 2024
d119074
fix build errors
BenAlvo1 Sep 18, 2024
941b876
check
BenAlvo1 Sep 18, 2024
c820b4b
linter
BenAlvo1 Sep 18, 2024
9a7d999
linter
BenAlvo1 Sep 18, 2024
0d6736b
linter
BenAlvo1 Sep 18, 2024
4955363
check
BenAlvo1 Sep 18, 2024
16dd3ba
fix download address
BenAlvo1 Sep 18, 2024
cbed05b
check
BenAlvo1 Sep 18, 2024
5a39c5f
fix
BenAlvo1 Sep 18, 2024
16f120d
fix console.error
BenAlvo1 Sep 18, 2024
ce29d03
close file
BenAlvo1 Sep 18, 2024
0127653
check
BenAlvo1 Sep 18, 2024
6dcd31a
check
BenAlvo1 Sep 18, 2024
137ba8e
check
BenAlvo1 Sep 18, 2024
4cfa921
fixing
BenAlvo1 Sep 19, 2024
ae35e16
refactor
BenAlvo1 Sep 22, 2024
1154bd7
add logs to check
BenAlvo1 Sep 22, 2024
191e010
check
BenAlvo1 Sep 22, 2024
91a42a3
check
BenAlvo1 Sep 22, 2024
7989121
check
BenAlvo1 Sep 22, 2024
4ea64c8
add logs
BenAlvo1 Sep 22, 2024
17c57f0
try add semaphore
BenAlvo1 Sep 22, 2024
3589e70
Update executable path
BenAlvo1 Sep 22, 2024
59b31f1
fix exec path config
BenAlvo1 Sep 22, 2024
813f4ac
download zip to tmp dir
BenAlvo1 Sep 22, 2024
7278271
check chmod location
BenAlvo1 Sep 22, 2024
cce52ab
add check.txt to resource
BenAlvo1 Sep 22, 2024
0a0bb62
check
BenAlvo1 Sep 22, 2024
8f667c2
remove download cli script
BenAlvo1 Sep 22, 2024
3fc30fa
refactor
BenAlvo1 Sep 22, 2024
d2d4cd4
refactor
BenAlvo1 Sep 22, 2024
6617877
update package.json
BenAlvo1 Sep 22, 2024
f0c0f7e
upgrade to node 16
BenAlvo1 Sep 22, 2024
056f0c3
refactor
BenAlvo1 Sep 22, 2024
106c992
add delete zip file after extracted
BenAlvo1 Sep 23, 2024
4dc6d3e
optimize dependencies
BenAlvo1 Sep 23, 2024
0d53422
remove unessecary dependency
BenAlvo1 Sep 23, 2024
faf444c
fix
BenAlvo1 Sep 23, 2024
8781a0a
re trigger scan
BenAlvo1 Sep 23, 2024
e850c22
retrigger cx scan
BenAlvo1 Sep 23, 2024
1e7bc84
update cliDefaultVersion to 2.2.6
BenAlvo1 Sep 23, 2024
079cbd8
revert jest.config.js changes
BenAlvo1 Sep 23, 2024
44d50de
revert test package.json data changes
BenAlvo1 Sep 23, 2024
9f56f1a
added README.md to resource directory
BenAlvo1 Sep 23, 2024
bc49577
create resource dir if not exists
BenAlvo1 Sep 23, 2024
2baa423
check
BenAlvo1 Sep 23, 2024
875051b
fix
BenAlvo1 Sep 23, 2024
81063ab
set cli version
BenAlvo1 Sep 23, 2024
4830ef0
include version file in package
BenAlvo1 Sep 23, 2024
b7521a7
check
BenAlvo1 Sep 23, 2024
36cc32c
Update update-cli.yml
BenAlvo1 Sep 23, 2024
aebede7
update github actions
BenAlvo1 Sep 23, 2024
ddbe723
fix package.json
BenAlvo1 Sep 23, 2024
6aec7d2
delete enter
BenAlvo1 Sep 23, 2024
507e4ab
add commit sha
BenAlvo1 Sep 24, 2024
0e29919
Update update-cli.yml
BenAlvo1 Sep 24, 2024
73d02a9
added singleton and factory design patterns to CxWrapper
BenAlvo1 Sep 24, 2024
26f46cc
delete unused set/get config
BenAlvo1 Sep 24, 2024
52e1399
refactor
BenAlvo1 Sep 24, 2024
b31a7e8
remove uneeded semaphore from CxInstaller.ts
BenAlvo1 Sep 24, 2024
e5bf9c7
remove semaphore import
BenAlvo1 Sep 24, 2024
6e69b68
added private and public to CxInstaller functions
BenAlvo1 Sep 24, 2024
3b0311d
make CxWrapper constructor private
BenAlvo1 Sep 24, 2024
feb72f8
added "multiple singleton" - one for each different scan configuratio…
BenAlvo1 Sep 24, 2024
01263d0
fix linter
BenAlvo1 Sep 24, 2024
74f1344
resolve conversations
BenAlvo1 Sep 24, 2024
b541284
delete unecessery clone
BenAlvo1 Sep 24, 2024
8c3ddbb
add comment
BenAlvo1 Sep 24, 2024
ba24745
fix linter
BenAlvo1 Sep 24, 2024
4c0632b
revert delete checkExecutableExists
BenAlvo1 Sep 24, 2024
f0c3cb7
make CxWrapperFactory.ts interface and object
BenAlvo1 Sep 24, 2024
49b1bd0
[create-pull-request] automated change (#16)
OrShamirCM Sep 30, 2024
38d8d0e
[create-pull-request] automated change (#18)
OrShamirCM Oct 1, 2024
3310a07
Revert "[create-pull-request] automated change (#18)"
cx-ben-alvo Oct 1, 2024
642bcfe
[create-pull-request] automated change (#20)
OrShamirCM Oct 1, 2024
3e9f9d3
add getVersionFilePath
BenAlvo1 Oct 6, 2024
a51342b
[create-pull-request] automated change (#22)
OrShamirCM Oct 6, 2024
f812c41
Revert "[create-pull-request] automated change (#22)"
cx-ben-alvo Oct 6, 2024
1b57b61
change to version 1.0.0
BenAlvo1 Oct 6, 2024
c87d2ba
chnage to version 1.0.0
BenAlvo1 Oct 6, 2024
1fa465f
[create-pull-request] automated change (#24)
OrShamirCM Oct 6, 2024
1093c2c
[create-pull-request] automated change (#26)
OrShamirCM Oct 7, 2024
c07ae49
change test execution to be synchronized
BenAlvo1 Nov 10, 2024
a432599
add cliInstalledVersion
BenAlvo1 Nov 10, 2024
16f6b87
add proxy support
BenAlvo1 Nov 10, 2024
76ec28c
implemented httpClient and Client interface. Added arm support for li…
BenAlvo1 Nov 10, 2024
bbcf2d2
refactor getArchitecture
BenAlvo1 Nov 10, 2024
7fa9038
refactor
BenAlvo1 Nov 10, 2024
5c69e44
add tupe to client feild in CxInstaller.ts
BenAlvo1 Nov 10, 2024
426a667
remove unnecessary log
BenAlvo1 Nov 10, 2024
f93cc72
refactor
BenAlvo1 Nov 11, 2024
d94bc85
Added unit tests
BenAlvo1 Nov 11, 2024
0c4d05a
update test
BenAlvo1 Nov 11, 2024
f67154f
fix tests
BenAlvo1 Nov 11, 2024
1470e8d
added astClient
BenAlvo1 Nov 11, 2024
c191e98
[create-pull-request] automated change (#29)
OrShamirCM Nov 12, 2024
3380a49
upgrade cli version
BenAlvo1 Nov 13, 2024
69feb73
comment vorpal tests
BenAlvo1 Nov 13, 2024
af14e53
comment vorpal test
BenAlvo1 Nov 13, 2024
5b0f46d
upgrade to node 20
BenAlvo1 Nov 13, 2024
e46ff3d
fix cxInstaller tests
BenAlvo1 Nov 13, 2024
4a41c65
decrease branches coverage
BenAlvo1 Nov 13, 2024
cf6d1b1
upgrade
cx-sarah-chen Nov 7, 2024
e21a720
Revert "[create-pull-request] automated change (#29)"
cx-ben-alvo Nov 13, 2024
51c0eb6
upgrade cli to 2.3.4
BenAlvo1 Nov 14, 2024
b9aa7c0
[create-pull-request] automated change (#32)
OrShamirCM Nov 14, 2024
d0ec359
[create-pull-request] automated change (#33)
OrShamirCM Nov 14, 2024
3e3d0b0
Update checkmarx-ast-cli to 2.3.5
cx-ben-alvo Nov 18, 2024
a06d27c
[create-pull-request] automated change (#35)
OrShamirCM Nov 18, 2024
c8c1622
[create-pull-request] automated change (#37)
OrShamirCM Nov 18, 2024
19ebf17
Revert "[create-pull-request] automated change (#37)"
cx-ben-alvo Nov 18, 2024
1c3b83a
[create-pull-request] automated change (#39)
OrShamirCM Nov 18, 2024
893ba26
Revert "[create-pull-request] automated change (#39)"
cx-ben-alvo Nov 18, 2024
18831fa
[create-pull-request] automated change (#41)
OrShamirCM Nov 18, 2024
6dacceb
[create-pull-request] automated change (#42)
OrShamirCM Nov 18, 2024
5fc8202
uncomment asca tests
BenAlvo1 Nov 26, 2024
5cc43d8
Merge branch 'other/sync-wrapper'
BenAlvo1 Nov 26, 2024
2d43ac6
Delete .github/workflows/ast-scan.yml
cx-ben-alvo Nov 26, 2024
023cb69
Revert decreasing of brnach coverage
BenAlvo1 Nov 26, 2024
2a6b6b7
CODEOWNERS
BenAlvo1 Nov 27, 2024
d545af0
Merge branch 'main' into other/benalvo/sync-wrapper
cx-ben-alvo Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = {
collectCoverageFrom: ['**/*.{ts,tsx}', '!**/*.d.ts', '!**/node_modules/**'],
coverageThreshold: {
"global": {
"branches": 60,
"branches": 65,
"functions": 80,
"lines": 80,
"statements": 80
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default class VorpalScanDetail {
export default class AscaScanDetail {
ruleId: number;
language: string;
ruleName: string;
Expand Down
12 changes: 6 additions & 6 deletions src/main/vorpal/CxVorpal.ts → src/main/asca/CxAsca.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import VorpalScanDetail from "./VorpalScanDetail";
import AscaScanDetail from "./AscaScanDetail";

export default class CxVorpal {
export default class CxAsca {
requestId: string;
status: boolean;
message: string;
scanDetails: VorpalScanDetail[];
scanDetails: AscaScanDetail[];
error: any;

constructor() {
Expand All @@ -15,16 +15,16 @@ export default class CxVorpal {
this.error = null;
}

static parseScan(resultObject: any): CxVorpal {
const scan = new CxVorpal();
static parseScan(resultObject: any): CxAsca {
const scan = new CxAsca();
scan.requestId = resultObject.request_id;
scan.status = resultObject.status;
scan.message = resultObject.message;
scan.error = resultObject.error;

if (resultObject.scan_details instanceof Array) {
scan.scanDetails = resultObject.scan_details.map((detail: any) => {
const scanDetail = new VorpalScanDetail();
const scanDetail = new AscaScanDetail();
scanDetail.ruleId = detail.rule_id;
scanDetail.language = detail.language;
scanDetail.ruleName = detail.rule_name;
Expand Down
6 changes: 3 additions & 3 deletions src/main/wrapper/CxConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export enum CxConstants {
FORMAT_HTML_CLI = "summaryHTML",
FILTER = "--filter",
SCAN_ID = "--scan-id",
CMD_VORPAL = "vorpal",
CMD_ASCA = "asca",
SOURCE_FILE = "--file-source",
VORPAL_UPDATE_VERSION = "--vorpal-latest-version",
ASCA_UPDATE_VERSION = "--asca-latest-version",
PROJECT_ID = "--project-id",
SIMILARITY_ID = "--similarity-id",
QUERY_ID = "--query-id",
Expand All @@ -81,7 +81,7 @@ export enum CxConstants {
ADDITONAL_PARAMS = "--additional-params",
ENGINE = "--engine",
SCAN_TYPE = "CxScan",
SCAN_VORPAL = "CxVorpal",
SCAN_ASCA = "CxAsca",
PROJECT_TYPE = "CxProject",
PREDICATE_TYPE = "CxPredicate",
CODE_BASHING_TYPE = "CxCodeBashing",
Expand Down
8 changes: 4 additions & 4 deletions src/main/wrapper/CxWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ export class CxWrapper {
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_TYPE);
}

async scanVorpal(sourceFile: string, updateVersion = false, agent?: string | null): Promise<CxCommandOutput> {
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_VORPAL, CxConstants.SOURCE_FILE, sourceFile];
async scanAsca(sourceFile: string, updateVersion = false, agent?: string | null): Promise<CxCommandOutput> {
const commands: string[] = [CxConstants.CMD_SCAN, CxConstants.CMD_ASCA, CxConstants.SOURCE_FILE, sourceFile];

if (updateVersion) {
commands.push(CxConstants.VORPAL_UPDATE_VERSION);
commands.push(CxConstants.ASCA_UPDATE_VERSION);
}
if (agent) {
commands.push(CxConstants.AGENT);
Expand All @@ -165,7 +165,7 @@ export class CxWrapper {

commands.push(...this.initializeCommands(false));
const exec = new ExecutionService();
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_VORPAL);
return await exec.executeCommands(this.config.pathToExecutable, commands, CxConstants.SCAN_ASCA);
}

async scanCancel(id: string): Promise<CxCommandOutput> {
Expand Down
8 changes: 4 additions & 4 deletions src/main/wrapper/ExecutionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import CxKicsRemediation from "../remediation/CxKicsRemediation";
import CxScaRealTime from "../scaRealtime/CxScaRealTime";
import CxChat from "../chat/CxChat";
import CxMask from "../mask/CxMask";
import CxVorpal from "../vorpal/CxVorpal";
import CxAsca from "../asca/CxAsca";

let skipValue = false;
const fileSourceFlag = "--file-source"
Expand Down Expand Up @@ -200,9 +200,9 @@ export class ExecutionService {
const scans = CxScan.parseProject(resultObject);
cxCommandOutput.payload = scans;
break;
case CxConstants.SCAN_VORPAL:
const vorpal = CxVorpal.parseScan(resultObject);
cxCommandOutput.payload = [vorpal];
case CxConstants.SCAN_ASCA:
const asca = CxAsca.parseScan(resultObject);
cxCommandOutput.payload = [asca];
break;
case CxConstants.PROJECT_TYPE:
const projects = CxProject.parseProject(resultObject);
Expand Down
82 changes: 41 additions & 41 deletions src/tests/ScanTest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,46 +127,46 @@ describe("ScanCreate cases", () => {
expect(aiEnabled).toBeDefined();
})

// it('ScanVorpal fail case Without extensions', async () => {
// const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
// const cxCommandOutput: CxCommandOutput = await auth.scanVorpal("tsc/tests/data/python-file");
// console.log(" Json object from failure case: " + JSON.stringify(cxCommandOutput));
//
// expect(cxCommandOutput.payload[0].error.description).toEqual("The file name must have an extension.");
// expect(cxCommandOutput.exitCode).toBe(0);
// expect(cxCommandOutput.payload[0].status).toBeUndefined();
// });

// it('ScanVorpal Successful case', async () => {
// const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
// const cxCommandOutput: CxCommandOutput = await auth.scanVorpal("tsc/tests/data/python-vul-file.py");
// console.log("Json object from scanVorpal successful case: " + JSON.stringify(cxCommandOutput));
// const scanObject = cxCommandOutput.payload.pop();
// expect(cxCommandOutput.payload).toBeDefined();
// expect(cxCommandOutput.exitCode).toBe(0);
// expect(scanObject.status).toEqual(true);
// });
//
// it('ScanVorpal with complex name Successful case', async () => {
// const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
// const cxCommandOutput: CxCommandOutput = await auth.scanVorpal("tsc/tests/data/var express = require('express';.js");
// console.log("Json object from scanVorpal successful case: " + JSON.stringify(cxCommandOutput));
// const scanObject = cxCommandOutput.payload.pop();
// expect(cxCommandOutput.payload).toBeDefined();
// expect(cxCommandOutput.exitCode).toBe(0);
// expect(scanObject.status).toEqual(true);
// });
//
// it('ScanVorpal Successful case with update version', async () => {
// const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
// const cxCommandOutput: CxCommandOutput = await auth.scanVorpal("tsc/tests/data/python-vul-file.py", true);
// console.log("Json object from scanVorpal successful case with update version: " + JSON.stringify(cxCommandOutput));
// const scanObject = cxCommandOutput.payload.pop();
// expect(cxCommandOutput.payload).toBeDefined();
// expect(cxCommandOutput.exitCode).toBe(0);
// expect(scanObject.status).toEqual(true);
// expect(Number.isInteger(scanObject.scanDetails[0].line)).toBe(true);
// expect(typeof scanObject.scanDetails[0].description).toBe('string');
// });
it('ScanAsca fail case Without extensions', async () => {
const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
const cxCommandOutput: CxCommandOutput = await auth.scanAsca("tsc/tests/data/python-file");
console.log(" Json object from failure case: " + JSON.stringify(cxCommandOutput));

expect(cxCommandOutput.payload[0].error.description).toEqual("The file name must have an extension.");
expect(cxCommandOutput.exitCode).toBe(0);
expect(cxCommandOutput.payload[0].status).toBeUndefined();
});

it('ScanAsca Successful case', async () => {
const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
const cxCommandOutput: CxCommandOutput = await auth.scanAsca("tsc/tests/data/python-vul-file.py");
console.log("Json object from scanAsca successful case: " + JSON.stringify(cxCommandOutput));
const scanObject = cxCommandOutput.payload.pop();
expect(cxCommandOutput.payload).toBeDefined();
expect(cxCommandOutput.exitCode).toBe(0);
expect(scanObject.status).toEqual(true);
});

it('ScanAsca with complex name Successful case', async () => {
const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
const cxCommandOutput: CxCommandOutput = await auth.scanAsca("tsc/tests/data/var express = require('express';.js");
console.log("Json object from scanAsca successful case: " + JSON.stringify(cxCommandOutput));
const scanObject = cxCommandOutput.payload.pop();
expect(cxCommandOutput.payload).toBeDefined();
expect(cxCommandOutput.exitCode).toBe(0);
expect(scanObject.status).toEqual(true);
});

it('ScanAsca Successful case with update version', async () => {
const auth = await cxWrapperFactory.createWrapper(cxScanConfig);
const cxCommandOutput: CxCommandOutput = await auth.scanAsca("tsc/tests/data/python-vul-file.py", true);
console.log("Json object from scanAsca successful case with update version: " + JSON.stringify(cxCommandOutput));
const scanObject = cxCommandOutput.payload.pop();
expect(cxCommandOutput.payload).toBeDefined();
expect(cxCommandOutput.exitCode).toBe(0);
expect(scanObject.status).toEqual(true);
expect(Number.isInteger(scanObject.scanDetails[0].line)).toBe(true);
expect(typeof scanObject.scanDetails[0].description).toBe('string');
});

});