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

PA-11096 generic "otherOptions" argument for passing command line extras #73

Merged
merged 3 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The basic command to run a baseline scan would look like:
| `--oauthTokenUrl` | None | The authentication URL that grants the access_token. |
| `--oauthParameters` | None | Parameters to be added to the oauth token request. (eg --oauthParameters="client_id:clientID, client_secret:clientSecret, grant_type:client_credentials")
| `--disableRules` | None | Comma separated list of ZAP rules IDs to disable. List for reference https://www.zaproxy.org/docs/alerts/ |
| `--otherOptions` | None | Additional command line arguments for items not supported by the set of parameters above |

#### Config File Definition
``` yaml
Expand Down
20 changes: 18 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def __init__(self):
self.sarif_destination: Optional[str] = None
self.disable_rules: Optional[str] = None

# allows passing other command line options directly to the script
self.other_options: Optional[str] = None

self.scan_mode_map: Dict = {
Constants.BASELINE: self.baseline_scan,
Constants.FULL_SCAN: self.full_scan,
Expand Down Expand Up @@ -262,6 +265,8 @@ def parse_configuration(self, configuration: Dict, target_url: str):
self.update_addons = True if str.lower(value) == "true" else False
elif key == "disableRules":
self.disable_rules = array_to_str(value)
elif key == "otherOptions":
self.other_options = array_to_str(value)

def __add_target_url_option__(self, args: List[str]) -> NoReturn:
if has_value(self.target_url):
Expand Down Expand Up @@ -356,7 +361,7 @@ def __generate_command__(self, args: List[str]) -> str:
self.__add_context_file_option__(args)
self.__add_ajax_spider_scan_option__(args)
self.__add_spider_minutes_option__(args)
log("Add ZAP Options?")

log(f"Auth Login: {str(self.auth_login_url)}")
log(f"Zap Options: {str(self.zap_options)}")
log(f"Cookies: {str(self.request_cookies)}")
Expand All @@ -366,7 +371,7 @@ def __generate_command__(self, args: List[str]) -> str:
self.__add_hook_option__(args)

self.__add_report_file__(args)

return " ".join(args)

def baseline_scan(self) -> str:
Expand Down Expand Up @@ -954,6 +959,13 @@ def parse_args(self) -> None:
default=None,
required=False
)
parser.add_argument(
"--otherOptions",
help="Other command line arguments sent directly to the script for items not supported by other command line arguments",
type=str,
nargs="*",
required=False,
)

# parse help argument
if "-hf" in sys.argv or "--helpFormatted" in sys.argv:
Expand Down Expand Up @@ -1029,6 +1041,10 @@ def run_analysis(self) -> None:
if self.zap_options:
command = f"{command} {Constants.ZAP_OPTIONS} \"{self.zap_options}\""

if self.other_options:
log(f"Other Options: {str(self.other_options)}")
command = f"{command} {self.other_options}"

log(f"Executing {self.scan_mode} scan")
soos_dast_start_response = self.__make_soos_start_analysis_request__(command)

Expand Down