[K9VULN-12480] feat: Azure Agentless Scanner - Cloud Shell wizard scaffolding & preflight (Step 1)#152
Conversation
|
codex review |
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7051ef8d6b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
gpalmz
left a comment
There was a problem hiding this comment.
Thanks for doing this! I think there are quite a few opportunities to consolidate with existing utils, and would definitely recommend doing so. Pointed out a couple specific ones, but there are probably others too. I'd recommend having claude read through the repo with this in mind and see what it can do.
…nly subscription access
…azure setup flows
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed87ff76c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed87ff76c1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
gpalmz
left a comment
There was a problem hiding this comment.
LGTM under the assumption that there will be a second pass for code consolidation. Thanks!
| def sigint_handler(signum, frame) -> None: | ||
| """Handle Ctrl+C gracefully.""" | ||
| print("\n\n⚠️ Setup interrupted by user (Ctrl+C)") | ||
| print(" Partial resources may have been created.") | ||
| print(" To clean up, run: terraform destroy") | ||
| sys.exit(130) | ||
|
|
||
|
|
||
| def session_timeout_handler() -> None: | ||
| """Handle session timeout.""" | ||
| print("\n\n⚠️ Session expired after 30 minutes.") | ||
| print(" If you still wish to complete the setup, re-run the command.") | ||
| print(" Terraform state is persisted, so it will continue where it left off.") | ||
| os._exit(1) | ||
|
|
||
|
|
||
| def start_session_timer() -> threading.Timer: | ||
| """Start a background timer for session timeout.""" | ||
| timer = threading.Timer(SESSION_TIMEOUT_MINUTES * 60, session_timeout_handler) | ||
| timer.daemon = True | ||
| timer.start() | ||
| return timer | ||
|
|
||
|
|
||
| def print_session_warning() -> None: | ||
| """Print Cloud Shell session timeout warning.""" | ||
| print() | ||
| print(f"⚠️ Note: This session will timeout after {SESSION_TIMEOUT_MINUTES} minutes.") | ||
| print(" If your session expires, generate a new workflow ID from the Datadog UI") | ||
| print(" and re-run the command. Terraform state is persisted, so it will") | ||
| print(" continue where it left off.") | ||
|
|
||
|
|
||
| def validate_credentials_and_workflow(config, reporter: Reporter) -> None: | ||
| """Validate Datadog credentials and workflow ID before starting setup. | ||
|
|
||
| Exits the process if validation fails. | ||
| """ | ||
| try: | ||
| validate_datadog_api_key(reporter, config.api_key, config.site) | ||
| validate_datadog_app_key(reporter, config.api_key, config.app_key, config.site) | ||
| except DatadogCredentialsError as e: | ||
| reporter.error(e.message) | ||
| if e.detail: | ||
| print(f" {e.detail}") | ||
| sys.exit(1) | ||
|
|
||
| if not reporter.is_valid_workflow_id(): | ||
| print( | ||
| f"Workflow ID {config.workflow_id} has already been used. " | ||
| "Please start a new workflow from the Datadog UI." | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| reporter.handle_login_step() |
There was a problem hiding this comment.
Noting for later: lots of potential for consolidation with these
There was a problem hiding this comment.
yes, I will consolidate this in the next PR
|
Thanks a lot for the deep review and all the feedback! |
What does this PR do?
Adds the initial scaffolding for an Azure Cloud Shell wizard that will deploy the Agentless Scanner infrastructure via Terraform, mirroring the existing GCP implementation in
gcp/agentless/.This PR implements Step 1 (Preflight Checks) end-to-end, with the remaining 5 steps stubbed out for follow-up PRs.
Why?
The current Azure agentless setup relies on ARM templates and per-subscription manual configuration. This Cloud Shell wizard will provide a streamlined, end-to-end setup experience (target: P95 < 5 minutes) with:
Related
gcp/agentless/linkDataDog/terraform-module-datadog-agentless-scanner/azure/linkWhat's included
config.pyDD_API_KEY,DD_SITE,SCANNER_SUBSCRIPTION,SCANNER_LOCATIONS,SUBSCRIPTIONS_TO_SCAN, etc.) into a typedConfigdataclass with validationerrors.pySetupError→AzureAuthenticationError,AzureAccessError,ResourceProviderError,KeyVaultError,TerraformError, etc.)shell.pyrun_command(),az_cli()with JSON parsing,az_cli_checked()requests.pyconsole_reporter.pyreporter.py/api/unstable/integration/azure/workflow/azure-agentless-setup)preflight.pymain.pydeploycommand. Step 1 wired, steps 2–6 are TODO stubsbuild.sh.pyzzipapp (same pattern as GCP)test_config.pyDeploy steps overview
main.tf+terraform.tfvarsterraform initwith Azure Storage backendterraform applyHow to test