Skip to content

Commit d4ee13b

Browse files
author
Jay Nanduri
committed
Added config to create scan from cx.exe file
1 parent 4da8e55 commit d4ee13b

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

cx.exe

23.6 MB
Binary file not shown.

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "ast-cli-javascript-wrapper",
3+
"version": "1.0.0",
4+
"description": "AST CLI Javascript wrapper",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/CheckmarxDev/ast-cli-javascript-wrapper.git"
12+
},
13+
"author": "Jay Nanduri",
14+
"license": "ISC",
15+
"bugs": {
16+
"url": "https://github.com/CheckmarxDev/ast-cli-javascript-wrapper/issues"
17+
},
18+
"homepage": "https://github.com/CheckmarxDev/ast-cli-javascript-wrapper#readme"
19+
}

src/CxAuth.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
let spawn = require('child_process').spawn;
2+
let CxScanConfig = require('./CxScanConfig.js');
3+
let loc = "cx.exe ";
4+
let prc = null;
5+
let scanCreate = function(cxScanConfig) {
6+
7+
if(cxScanConfig != null) {
8+
var params = ['scan','create','-v','--format','json'];
9+
if(cxScanConfig.baseuri != null) {
10+
params.push('--base-uri');
11+
params.push(cxScanConfig.baseuri)
12+
}
13+
if(cxScanConfig.token != null) {
14+
params.push('--token');
15+
params.push(cxScanConfig.token);
16+
}
17+
else if(cxScanConfig.key != null && cxScanConfig.secret != null) {
18+
params.push('--client-id');
19+
params.push(cxScanConfig.key);
20+
params.push('--secret');
21+
params.push(cxScanConfig.secret);
22+
}
23+
else {
24+
console.log("Did not receive KEY/SECRET/TOKEN");
25+
}
26+
27+
if(cxScanConfig.paramMap != null) {
28+
for(let indKey of cxScanConfig.paramMap.keys()) {
29+
params.push(indKey);
30+
params.push(cxScanConfig.paramMap.get(indKey));
31+
}
32+
}
33+
//console.log(params);
34+
// prc = spawn("cx.exe",['scan','create','--base-uri','http://demo.ast-cloud.com','--client-id','CxFlow','--secret','440b05e6-0503-455b-9361-8ee91a6c24cc','--project-name','JayJSWrapper','--project-type',
35+
// 'sast','--preset-name','Checkmarx Default', '-d', '.'
36+
// ]);
37+
prc = spawn(loc,params)
38+
//prc.stdout.setEncoding('utf8');
39+
prc.stdout.on('data', function (data) {
40+
var str = data.toString()
41+
var lines = str.split(/(\r?\n)/g);
42+
console.log(lines.join(""));
43+
});
44+
45+
prc.on('close', function (code) {
46+
console.log('process exit code ' + code);
47+
});
48+
}
49+
else {
50+
console.log("Pass the Cx Scan Config object");
51+
}
52+
53+
}
54+
55+
// let paramMap = new Map();
56+
// paramMap.set("--project-name","JSScanTest");
57+
// paramMap.set("--project-type","sast");
58+
// paramMap.set("--preset-name","Checkmarx Default");
59+
// paramMap.set("-d",".");
60+
// let scanConfig = new CxScanConfig("http://demo.ast-cloud.com",null,"CxFlow","440b05e6-0503-455b-9361-8ee91a6c24cc",null,paramMap)
61+
// scanCreate(scanConfig);

src/CxScanConfig.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
class CxScanConfig {
2+
constructor(baseuri, authType, key, secret, token, paramMap) {
3+
this._baseuri = baseuri;
4+
this._authType = authType;
5+
this._key = key;
6+
this._secret = secret;
7+
this._token = token;
8+
this._paramMap = paramMap
9+
}
10+
11+
12+
get baseuri() {
13+
return this._baseuri;
14+
}
15+
16+
set baseuri(value) {
17+
this._baseuri = value;
18+
}
19+
20+
get authType() {
21+
return this._authType;
22+
}
23+
24+
set authType(value) {
25+
this._authType = value;
26+
}
27+
28+
get key() {
29+
return this._key;
30+
}
31+
32+
set key(value) {
33+
this._key = value;
34+
}
35+
36+
get secret() {
37+
return this._secret;
38+
}
39+
40+
set secret(value) {
41+
this._secret = value;
42+
}
43+
44+
get token() {
45+
return this._token;
46+
}
47+
48+
set token(value) {
49+
this._token = value;
50+
}
51+
52+
get paramMap() {
53+
return this._paramMap;
54+
}
55+
56+
set paramMap(value) {
57+
this._paramMap = value;
58+
}
59+
}
60+
61+
module.exports = CxScanConfig

0 commit comments

Comments
 (0)