Skip to content
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

make enum params case insensitive #77

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
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, "Click");
},
});

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