The provenance nobody means and the bounds an entry has are now refused by the image
OPEN-23's behaviour was implemented and its integration tests were green, and not
one gate had ever sent any of it to the container an operator deploys: grep over
scripts/compose-smoke.sh for enigne, expiresInMinutes and 512 returned nothing.
The item's own steps-to-reproduce are a curl against a container, and no gate ran
one.
New scene, 19 assertions, compose gate 113 -> 132, measured 132 passed / 0 failed
on the host:
GET ?source=enigne 400, naming the set and echoing the value
DELETE ?source=enigne 400, with the two operator rows still there by
name and by count
GET ?source= OPERATOR 200 and exactly the two rows it means
expiresInMinutes 0 and -5 400 naming 1..5256000, and nothing written
expiresInMinutes left out expiresAt null - still the only way to say never
reason / note of 513 400 naming the length, and neither row written
note of 512 204, so the bound is not off by one
The scene writes the operator list it then proves it protected, because the scenes
before it clear the tables: an assertion that the refused delete changed nothing
would otherwise have compared 0 with 0 and passed for nothing. It removes what it
wrote and prints the block counts again.
Teeth re-measured at this head rather than carried forward, against the 11 cases of
ProvenanceAndLimitsTests: unknown provenance accepted as all -> 5 failed; the
expiresInMinutes gate disabled -> 3 failed; the note/reason length gate disabled ->
1 failed. Those are exactly the three numbers AC7 states. All three reverted; the
tree carries no mutation.
This commit is contained in:
@@ -514,6 +514,114 @@ admin -X DELETE "$EDGE/admin-api/blocks?source=engine" >/dev/null
|
||||
check 'and putting the original status back is reflected in the policy read' "$ENGINE_BEFORE" \
|
||||
"$(admin "$EDGE/admin-api/policy" | jval engineBlockStatus)"
|
||||
|
||||
echo '- a provenance nobody means is refused, and the bounds an entry has are enforced'
|
||||
# OPEN-23 measured on the shipped image before this scene existed: with two operator
|
||||
# blocks and three engine bans, GET /admin-api/blocks?source=enigne answered 200 with
|
||||
# the operator list, and DELETE ?source=enigne answered 200 {"deleted":1} and left
|
||||
# operator=0 engine=3. A typo for "engine" erased the list an operator builds by hand —
|
||||
# the one thing this API's own comment says it exists to prevent. The bounds are the
|
||||
# same class of mistake: expiresInMinutes 0 and -5 both meant "never expires" on the
|
||||
# control that outranks every ban, and a 1 MB reason was accepted with 204 and came
|
||||
# back as ~1,000,287 bytes of listing.
|
||||
# The scenes before this one clear the block tables, so the list is empty when the
|
||||
# scene starts and a "nothing was deleted" assertion would compare 0 with 0. The scene
|
||||
# therefore writes the list it needs to protect, and says so.
|
||||
SRC_A=203.0.113.241
|
||||
SRC_B=203.0.113.242
|
||||
SRC_OP=203.0.113.231
|
||||
SRC_TTL=203.0.113.232
|
||||
SRC_LONG=203.0.113.233
|
||||
for S in "$SRC_A" "$SRC_B"; do
|
||||
admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$S\",\"reason\":\"the list this scene protects\"}" "$EDGE/admin-api/blocks" >/dev/null
|
||||
done
|
||||
check 'the operator list this scene protects has two rows' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['source']=='operator'")"
|
||||
check 'a provenance this endpoint never heard of is a 400' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/blocks?live=false&source=enigne")"
|
||||
BOGUS=$(admin "$EDGE/admin-api/blocks?live=false&source=enigne")
|
||||
names_set=no
|
||||
case "$BOGUS" in
|
||||
*'source must be operator|engine|all'*) names_set=yes ;;
|
||||
esac
|
||||
check 'and the refusal names the set it is outside' 'yes' "$names_set"
|
||||
echoes_value=no
|
||||
case "$BOGUS" in
|
||||
*'enigne'*) echoes_value=yes ;;
|
||||
esac
|
||||
check 'and echoes back the value it refused' 'yes' "$echoes_value"
|
||||
check 'a delete with that provenance is refused too' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X DELETE "$EDGE/admin-api/blocks?source=enigne")"
|
||||
check 'and the operator list is still the two rows it was' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['source']=='operator'")"
|
||||
check 'both of them by name, not just by count' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" \
|
||||
| jcount "b['sourceKey']=='$SRC_A' or b['sourceKey']=='$SRC_B'")"
|
||||
check 'while the documented filter still answers, spaced and cased' '200' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" "$EDGE/admin-api/blocks?live=false&source=%20OPERATOR%20")"
|
||||
check 'and that filter returns exactly the two rows it means' '2' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false&source=operator" | jcount "b['source']=='operator'")"
|
||||
check 'a TTL of zero is refused, not read as never' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"zero ttl\",\"expiresInMinutes\":0}" "$EDGE/admin-api/allow")"
|
||||
ZERO_BODY=$(admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"zero ttl\",\"expiresInMinutes\":0}" "$EDGE/admin-api/allow")
|
||||
names_range=no
|
||||
case "$ZERO_BODY" in
|
||||
*'expiresInMinutes must be 1..5256000'*) names_range=yes ;;
|
||||
esac
|
||||
check 'and the refusal names the range it is outside' 'yes' "$names_range"
|
||||
check 'and the exemption it refused was never written' '0' \
|
||||
"$(admin "$EDGE/admin-api/allow" | jcount "b['match']=='$SRC_OP'")"
|
||||
check 'a negative TTL is refused with the same range' '400' \
|
||||
"$(code -H "X-Admin-Token: $OPENWAF_ADMIN_TOKEN" -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_OP\",\"note\":\"negative ttl\",\"expiresInMinutes\":-5}" "$EDGE/admin-api/allow")"
|
||||
admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_TTL\",\"note\":\"no ttl field\"}" "$EDGE/admin-api/allow" >/dev/null
|
||||
check 'leaving the field out is still the only way to say never' 'null' \
|
||||
"$(admin "$EDGE/admin-api/allow" | python3 -c "import json,sys
|
||||
d=json.load(sys.stdin)
|
||||
print(','.join('null' if b['expiresAt'] is None else 'set' for b in d if b['match']=='$SRC_TTL'))")"
|
||||
LONG=$(python3 -c 'print("R"*513)')
|
||||
REASON_BODY=$(admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"ip\":\"$SRC_LONG\",\"reason\":\"$LONG\"}" "$EDGE/admin-api/blocks")
|
||||
reason_named=no
|
||||
case "$REASON_BODY" in
|
||||
*'reason must be at most 512 characters; got 513'*) reason_named=yes ;;
|
||||
esac
|
||||
check 'a reason past the column is refused with its length' 'yes' "$reason_named"
|
||||
check 'and the block it refused was never written' '0' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['sourceKey']=='$SRC_LONG'")"
|
||||
NOTE_BODY=$(admin -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_LONG\",\"note\":\"$LONG\"}" "$EDGE/admin-api/allow")
|
||||
note_named=no
|
||||
case "$NOTE_BODY" in
|
||||
*'note must be at most 512 characters; got 513'*) note_named=yes ;;
|
||||
esac
|
||||
check 'a note past the column is refused with its length' 'yes' "$note_named"
|
||||
check 'and the exemption it refused was never written' '0' \
|
||||
"$(admin "$EDGE/admin-api/allow" | jcount "b['match']=='$SRC_LONG'")"
|
||||
AT_LIMIT=$(python3 -c 'print("R"*512)')
|
||||
# Body and status from one request: a second POST for the same match would answer
|
||||
# 409 and prove nothing about the limit.
|
||||
AT_RESP=$(admin -w '\n%{http_code}' -X POST -H 'Content-Type: application/json' \
|
||||
-d "{\"match\":\"$SRC_LONG\",\"note\":\"$AT_LIMIT\"}" "$EDGE/admin-api/allow")
|
||||
AT_CODE=${AT_RESP##*$'\n'}
|
||||
printf ' info the note at the limit answered %s: %s\n' "$AT_CODE" "$(printf '%s' "${AT_RESP%$'\n'*}" | head -c 90)"
|
||||
check 'while a note at the limit is accepted' '204' "$AT_CODE"
|
||||
# Leave the stack as the scenes after this one expect to find it.
|
||||
for M in "$SRC_TTL" "$SRC_LONG"; do
|
||||
AID=$(admin "$EDGE/admin-api/allow" | python3 -c "import json,sys
|
||||
print(','.join(str(b['id']) for b in json.load(sys.stdin) if b['match']=='$M'))")
|
||||
for I in ${AID//,/ }; do admin -X DELETE "$EDGE/admin-api/allow/$I" >/dev/null; done
|
||||
done
|
||||
for S in "$SRC_A" "$SRC_B"; do
|
||||
admin -X DELETE "$EDGE/admin-api/blocks?source=operator&key=$S" >/dev/null
|
||||
done
|
||||
printf ' info blocks after the scene: operator=%s engine=%s\n' \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['source']=='operator'")" \
|
||||
"$(admin "$EDGE/admin-api/blocks?live=false" | jcount "b['source']=='engine'")"
|
||||
|
||||
echo '- a pillar that stops reading its table says so'
|
||||
# Measured on the shipped image before this was fixed: with policy_settings
|
||||
# dropped out from under a running edge, GET /admin-api/policy kept answering the
|
||||
|
||||
Reference in New Issue
Block a user