Skip to content

Commit

Permalink
make enum params case insensitive (#77)
Browse files Browse the repository at this point in the history
* make enum params case insensitive

* use method from client library

* removed extra param in one method for test
  • Loading branch information
SOOS-JAlvarez committed Nov 8, 2023
1 parent 5a371d7 commit e951d92
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 41 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"check": "npm run format && npm run typecheck && npm outdated"
},
"dependencies": {
"@soos-io/api-client": "0.1.5",
"@soos-io/api-client": "0.1.6",
"argparse": "^2.0.1",
"axios": "^0.27.2",
"tslib": "^2.6.2"
Expand Down
44 changes: 9 additions & 35 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
convertStringToBase64,
sleep,
obfuscateProperties,
ensureEnumValue,
} from "@soos-io/api-client/dist/utilities";
import {
ScanStatus,
Expand Down Expand Up @@ -94,11 +95,7 @@ class SOOSDASTAnalysis {
help: "Target API format, OpenAPI, SOAP or GraphQL.",
required: false,
type: (value: string) => {
if (Object.values(ApiScanFormat).includes(value as ApiScanFormat)) {
return value as ApiScanFormat;
} else {
throw new Error(`Invalid Api Scan Format: ${value}`);
}
return ensureEnumValue(ApiScanFormat, value);
},
});

Expand Down Expand Up @@ -126,11 +123,7 @@ class SOOSDASTAnalysis {
default: FormTypes.Simple,
required: false,
type: (value: string) => {
if (Object.values(FormTypes).includes(value as FormTypes)) {
return value as FormTypes;
} else {
throw new Error(`Invalid submit action: ${value}`);
}
return ensureEnumValue(FormTypes, value);
},
});

Expand Down Expand Up @@ -158,11 +151,7 @@ class SOOSDASTAnalysis {
help: "Submit action to perform on form filled. Options: click or submit.",
required: false,
type: (value: string) => {
if (Object.values(SubmitActions).includes(value as SubmitActions)) {
return value as SubmitActions;
} else {
throw new Error(`Invalid submit action: ${value}`);
}
return ensureEnumValue(SubmitActions, value);
},
});

Expand Down Expand Up @@ -272,11 +261,7 @@ class SOOSDASTAnalysis {
default: LogLevel.INFO,
required: false,
type: (value: string) => {
if (value in LogLevel) {
return LogLevel[value as keyof typeof LogLevel];
} else {
throw new Error(`Invalid log level: ${value}`);
}
return ensureEnumValue(LogLevel, value);
},
});

Expand All @@ -296,11 +281,7 @@ class SOOSDASTAnalysis {
default: OnFailure.Continue,
required: false,
type: (value: string) => {
if (Object.values(OnFailure).includes(value as OnFailure)) {
return value as OnFailure;
} else {
throw new Error(`Invalid submit action: ${value}`);
}
return ensureEnumValue(OnFailure, value);
},
});

Expand All @@ -320,11 +301,7 @@ class SOOSDASTAnalysis {
help: "Output format for vulnerabilities: only the value SARIF is available at the moment",
required: false,
type: (value: string) => {
if (value in OutputFormat) {
return OutputFormat[value as keyof typeof OutputFormat];
} else {
throw new Error(`Invalid output format: ${value}`);
}
return ensureEnumValue(OutputFormat, value);
},
});

Expand Down Expand Up @@ -356,11 +333,7 @@ class SOOSDASTAnalysis {
default: ScanMode.Baseline,
required: false,
type: (value: string) => {
if (Object.values(ScanMode).includes(value as ScanMode)) {
return value as ScanMode;
} else {
throw new Error(`Invalid scan mode: ${value}`);
}
return ensureEnumValue(ScanMode, value);
},
});

Expand Down Expand Up @@ -447,6 +420,7 @@ class SOOSDASTAnalysis {
}

const zapCommandGenerator = new ZAPCommandGenerator(this.args);
soosLogger.info(`Generating ZAP command... ${this.args.scanMode}`);
const command = zapCommandGenerator.runCommandGeneration(this.args.scanMode);
soosLogger.info(`Running command: ${command}`);
await SOOSDASTAnalysis.runZap(command);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Visit https://aka.ms/tsconfig.json to read more about this file */
{
"compilerOptions": {
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"target": "ES2021", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
"outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
Expand Down

0 comments on commit e951d92

Please sign in to comment.