MoonBit Nginx security scanner for effective upstream TLS policies, source-aware CI checks and IPv4 access regression
git clone https://github.com/BeiLaDuo/moonnginx-access-audit.git
cd moonnginx-access-auditnode tools\moonnginx-access-audit.mjs security nginx.conf --root examples/security/risky --strict --format json
node tools\moonnginx-access-audit.mjs security nginx.conf --root examples/security/repaired --strict --format jsonnode tools\moonnginx-access-audit.mjs security nginx.conf --root examples/security/risky --format sarif > security.sarifnode tools\moonnginx-access-audit.mjs diff nginx.conf nginx.conf --root examples/regression/before --after-root examples/regression/after --host example.test --port 8080 --uri /admin/probe.txt --scope 127.0.0.0/8 --gate no-widening --format json
echo %ERRORLEVEL%node tools\moonnginx-access-audit.mjs expect nginx.conf 127.0.0.2/31 --expect deny --root examples/regression/after --host example.test --port 8080 --uri /admin/probe.txt --format jsonnode tools\moonnginx-access-audit.mjs contexts nginx.conf --root examples/nginx/files --format json
node tools\moonnginx-access-audit.mjs probe nginx.conf 127.0.0.1 --root examples/nginx/files --context "http[1]/server[1]/location[2]" --format json
node tools\moonnginx-access-audit.mjs audit examples/ci/safe.conf --format jsonnode tools\moonnginx-access-audit.mjs audit examples/ci/risky.conf --format sarif > nginx.sarif
echo %ERRORLEVEL%| Command | Purpose |
|---|---|
| security CONFIG | Scan configuration security patterns, with evidence and remediation |
| contexts CONFIG | List structural selectors and effective rule origins |
| audit CONFIG | Produce findings and apply a release gate |
| probe CONFIG IP --context ID | Explain one IPv4 address decision |
| validate CONFIG | Check the supported configuration and its dependencies |
| request CONFIG IP --host HOST --uri PATH | Resolve a request and explain its address decision |
| diff BEFORE AFTER --host HOST --uri PATH | Compare address decisions, not configuration text |
| expect CONFIG CIDR --expect allow\|deny --host HOST --uri PATH | Require the outcome for every address in a subnet |
| Status | Meaning |
|---|---|
| 0 | Completed within the declared scope |
| 1 | Audit, diff or subnet expectation gate rejected the result |
| 2 | Invalid argument, file, encoding, syntax or include input |
| 3 | Unsupported or incomplete analysis |
| 4 | Resource budget exhausted |
moon update
moon run examples/nginx --target wasm-gc
moon run examples/regression --target wasm-gcmoon add BeiLaDuo/moonnginx-access-audit@0.5.0import {
"BeiLaDuo/moonnginx-access-audit/nginx" @adapter,
}moon update
python tools\check_toolchain.py
moon info
moon fmt --check
moon check --target all --deny-warn
moon build
moon test --target js --deny-warn
moon test --target wasm --deny-warn
moon test --target wasm-gc --deny-warn
moon build cmd/nginx-cli --target js --release --deny-warn
python tools\verify_files.py
python tools\verify_distribution.py
python tools\verify_ci_examples.py
python tools\verify_sarif.py
python tools\verify_regression.py
python tools\verify_security.py
python tools\verify_upstream_tls.py --nginx C:/tools/nginx/nginx.exe
moon package --list
python tools\verify_repository.py --check-packagefn AddressRange::new(first : IPv4, last : IPv4, source_count? : Int) -> Result[AddressRange, String]pub struct Decision {
matched : Bool
action : RuleAction
rule_id : String
block : String
} derive(Eq, Debug)pub struct Finding {
kind : FindingKind
severity : Severity
rule_id : String
related_rule_id : String
message : String
} derive(Eq, Debug)fn Finding::new(kind : FindingKind, severity : Severity, rule_id : String, message : String, related_rule_id? : String) -> Findingfn GatePolicy::new(name : String, max_critical : Int, max_warning : Int, max_risk_score : Int, allow_parse_errors? : Bool) -> Result[GatePolicy, String]pub struct GateResult {
policy : GatePolicy
passed : Bool
risk_score : Int
reasons : Array[GateReason]
} derive(Debug)pub struct ImportIssue {
line : Int
level : ImportIssueLevel
code : String
message : String
input : String
} derive(Eq, Debug)fn ImportIssue::new(line : Int, level : ImportIssueLevel, code : String, message : String, input : String) -> ImportIssuepub struct ImportReport {
format : ImportFormat
source_count : Int
rules : Array[Rule]
issues : Array[ImportIssue]
} derive(Debug)pub struct Rule {
id : String
action : RuleAction
block : CidrBlock
source_block : String
note : String
} derive(Eq, Debug)fn Rule::new(id : String, action : RuleAction, block : CidrBlock, source_block? : String, note? : String) -> Rulepub struct RuleChange {
kind : RuleChangeKind
before_id : String
after_id : String
block : String
message : String
} derive(Eq, Debug)fn RuleChange::new(kind : RuleChangeKind, before_id : String, after_id : String, block : String, message : String) -> RuleChangefn RuleSet::evaluate_gate(self : RuleSet, audit_policy : AuditPolicy, gate_policy : GatePolicy) -> GateResultInstall
Download zipMoonBit Nginx security scanner for effective upstream TLS policies, source-aware CI checks and IPv4 access regression