Skip to content

fix(config): print the effective attempts value in -print-config - #200

Closed
nova-loop wants to merge 1 commit into
TMHSDigital:mainfrom
nova-loop:fix/153-print-config-attempts
Closed

nova-loop wants to merge 1 commit into
TMHSDigital:mainfrom
nova-loop:fix/153-print-config-attempts

Conversation

@nova-loop

Copy link
Copy Markdown

Description

-print-config printed the raw -attempts flag value, so with no flags it showed attempts = "0" (default) while a scan uses 1. It now resolves attempts the same way a scan does:

  • resolveAttempts is split into a pure effectiveAttempts (same precedence rules, also reports whether -retries won) plus the existing deprecation warning, so -print-config can reuse the logic without printing the warning.
  • printConfig shows the effective value for attempts: 1 (default) with nothing set, the -attempts value when given, and the -retries value marked e.g. (flag, from retries) / (env, from retries) when that is what wins. If the two conflict at the same precedence (which a scan refuses), the raw value is kept.
  • CHANGELOG entry under Unreleased / Fixed.

Related Issue

Closes #153

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project
  • I have added/updated appropriate comments to the code
  • I have added tests that prove my fix is effective or that my feature works (TestPrintConfigEffectiveAttempts in main_config_test.go: default, -attempts, -retries, SUBENUM_RETRIES, and flag-beats-env)
  • New and existing unit tests pass locally with my changes (go test ./..., go vet ., gofmt)
  • I have updated the documentation accordingly (CHANGELOG)

I didn't run make lint (golangci-lint isn't installed in my environment), so CI's lint job is the check there.

Ethical Considerations

  • This change maintains or improves the security controls in the tool
  • This change follows the educational/legitimate security testing focus of the project
  • I have considered potential misuse cases and taken appropriate steps to prevent them (output-only change to -print-config)

Additional Information

Manual check: go run . -print-config now prints attempts = "1" (default), and go run . -print-config -retries 2 prints attempts = "2" (flag, from retries) without the deprecation warning.

This change was prepared with AI assistance; I reviewed the diff and ran the tests above.

@TMHSDigital

Copy link
Copy Markdown
Owner

Thank you for this. It's a careful fix, and the write-up made it easy to review.

#153 was fixed on main in 414f308 before this PR was reviewed, using the same approach (effectiveAttempts split out of resolveAttempts, and printConfig showing the effective value). Since then resolveAttempts was removed in e49aca4 (#166), so this branch no longer applies cleanly.

Your test covers cases the main fix didn't (SUBENUM_RETRIES, and a flag beating an env value), so I've taken TestPrintConfigEffectiveAttempts and your CHANGELOG entry into main in 6264675, with you as co-author. All five cases pass against the code on main.

Closing this as superseded. Thanks again, and contributions are welcome on the other open issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

-print-config shows attempts = 0 while the effective value is 1

2 participants