Skip to content

feat(guard): read curl's, wget's and gh api's options - #33

Merged
Bakhomious merged 1 commit into
mainfrom
step/guard-http
Nov 3, 2026
Merged

Bakhomious merged 1 commit into
mainfrom
step/guard-http

Conversation

@Bakhomious

Copy link
Copy Markdown
Contributor

What

guard-http, the next part of the guard (decision 51, fact 35): internal/guard now reads the options of curl, wget and gh api, and watches them only when they send data.

  • A request writes when it has a method other than GET and HEAD, or, with no method, data to send (-d, -F, --json, -T, wget's --post-data, gh's fields and --input, and the like).
  • curl's --next (-:) starts a request of its own; one that writes before it keeps the call watched.
  • wget's abbreviations (--meth=POST) and its -e settings (-e Post_Data=x) count, as wget reads them.
  • The values of short options are skipped, by each tool's help, so curl -H -d doesn't count as data.
  • gh api graphql always counts, since GraphQL posts its reads too.
  • Fail closed: an option, a method or a wget setting that only the run decides counts as a write; so do curl's -G with data and gh api -X=GET.
  • Known misses, in decision 51: a whole word of options that only the run decides (curl $OPTS), ~/.curlrc, -K, ~/.wgetrc, WGETRC, and curl's other protocols (FTP's -Q, telnet://).

Checks

  • mise run check: lint 0 issues, internal/guard at 100%, total 99.2%.
  • Probes: 137 of 140 mutants caught. The 3 that survive change nothing: curl's data and form renamed are still the start of other names that send data, and the last match in lookup gives the same part as the first.
  • Smoke: 28 scripts of my own through guard.Commands, each with the expected verdict.
  • Requests to a listener on 127.0.0.1 confirmed the facts: curl -X GET -d -XPOST sends a GET with a body, wget -O- --post-data=x a POST, curl --output-dir a GET; gh api sends GET for -X=GET and -XGET, POST for -f a=b and --input, and GET with a query for -X GET -f a=b.

The guard now watches curl, wget and gh api only when they send data:
by a method other than GET and HEAD, or, with no method, with data to
send. It follows each tool's way of reading its options (fact 35) and
fails closed on what only the run decides (decision 51).
@sonarqubecloud

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@Bakhomious
Bakhomious merged commit 443cc9e into main Nov 3, 2026
3 checks passed
@Bakhomious
Bakhomious deleted the step/guard-http branch November 3, 2026 20:30
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.

1 participant