Six negations about trusting a proxy assert nothing, including the nginx injection case #15
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/keel-nodebb#15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A bats test body has no assertions of its own: its verdict is the exit status of the last command it ran. Bash does not apply errexit to a negated command, so
! cmdon its own line decides the test when it is the final command of the body and is inert everywhere else.Six negations here are inert, and every one of them is about trusting a proxy.
tests/nginx.bats, the shipped conf.d default
Two of the four assertions ran.
tests/nodebb.bats, the validator and the renderer
! nodebb_valid_proxy "2001:db8::13; }"— the value that would close thegeoblock and append directives of its own. The injection case. Onlyhellodecided anything.geois on$realip_remote_addrand never on$remote_addr. That is the redirect loop the file's own comment warns about at length, and its guard did not run.What to do
Write every negation
run ! cmd, withbats_require_minimum_version 1.5.0, the ones in final position included, so that no line's meaning depends on its position.Watch for one thing while converting:
runreplaces$output, and several tests here dorun nodebb_proxy_conf …and then grep<<< "$output"more than once. A secondrun !reading<<< "$output"reads the first refutation's empty output and passes for a new reason. The rendered file has to be kept in a local first.Test plan
shellcheck --severity=error --include=SC2314overtests/*.batsreports nothing.bats tests/*.batsgreen with the six inert assertions live.tests/coverage.shat or above the committed threshold of 95.package / changelogpasses by reporting that nothing that ships changed.