moonnginx-access-audit

    MoonBit Nginx security scanner for effective upstream TLS policies, source-aware CI checks and IPv4 access regression

    cidr
    ipv4
    network
    audit
    security
    nginx
    cli
    Download zip
    Author
    Version
    0.5.0
    License
    Apache-2.0
    Last updated
    8 hours ago
    Downloads
    4

    #MoonNginx Access Audit

    Scan real Nginx configurations for security mistakes, then check unintended IPv4 access changes between configuration snapshots. The analysis is MoonBit.

    The security command checks expanded configuration trees for alias traversal, lost response headers, unsafe proxy targets/Host forwarding, rewrite-phase access bypass and other security mistakes. It scans nested and regex locations without requiring the limited request router to resolve a URL. Findings include source locations, evidence and remediation. Gixy-Next is the primary benchmark; this is an independently implemented subset, not a complete port.

    Version 0.5.0 reviews the effective upstream TLS policy for HTTPS, gRPC and uWSGI. A valid configuration can omit verification, or disable it in an included location even when the parent enabled it. The report tells you which upstream uses the policy and where the setting or default comes from.

    nginx -t checks configuration syntax and referenced files. A valid edit can still expose an admin path: adding one child deny replaces the entire inherited allow-list. This tool compares the resulting address decisions for a specified host, listener and URI, reports newly allowed/denied intervals, and fails CI when the change violates an explicit gate.

    Repository: https://github.com/BeiLaDuo/moonnginx-access-audit MoonBit module: BeiLaDuo/moonnginx-access-audit Participant and new Git author: 高本乾 · 3346147448@qq.com

    #Run without building

    Get the public source in CMD:

    git clone https://github.com/BeiLaDuo/moonnginx-access-audit.git cd moonnginx-access-audit

    Install Node.js 22.13 or newer. From this repository, run these commands in CMD:

    node 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 json

    The first example reports security mistakes and exits 1; the repaired example exits 0. A clean result means the implemented static checks found no issue, not that every Nginx module, request path or application is secure. Coverage diagnostics and resource errors must not be ignored. Export findings for CI:

    node tools\moonnginx-access-audit.mjs security nginx.conf --root examples/security/risky --format sarif > security.sarif

    For a before/after access regression:

    node 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%

    Expected: 1, newly_allowed_count: "16777214", with witnesses and both rule origins. Both snapshots use normal Nginx syntax. To express a regression requirement over a whole subnet:

    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 json

    Expected: 1 because .3 is unrestricted even though .2 is denied. Change after to before for a passing expectation. No service is started by these commands. Existing structural audit commands remain available:

    node 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 json

    The launcher uses a local release build first, then a debug build, then the shipped dist/moonnginx-access-audit.js. A source archive can run the shipped CLI without a MoonBit installation. Build first when modifying MoonBit code.

    To generate a report for code review:

    node tools\moonnginx-access-audit.mjs audit examples/ci/risky.conf --format sarif > nginx.sarif echo %ERRORLEVEL%

    The risky example returns 1, with a complete SARIF report. It does not upload anything to GitHub. See SARIF instructions for source paths, selectors, severity mapping and unsuccessful analyses.

    #What it models

    • Ordered allow/deny rules in HTTP, server and nested location contexts.
    • Whole-list inheritance: any local access rule replaces the parent's list.
    • First-match decisions, unreachable rules, broad allows, duplicate rules, CIDR normalization and unrestricted fallbacks.
    • Confined offline includes with source files, line numbers and include chains.
    • Input, include expansion, audit-work and expanded-report resource budgets.
    • Text, JSON and Markdown reports; SARIF 2.1.0 for the audit and security commands.
    • Request selection by literal IPv4 listener, exact host/default server and flat exact/prefix location; context ordinals may differ between snapshots.
    • Exact, scoped IPv4 decision differences and whole-subnet expectations, with replayable witnesses, source provenance and bounded comparison work.

    The parser is the existing Apache-2.0 LuoYunxin1/moonnginx@0.2.0 package. The include semantics, access analysis, reports, file CLI and tests are this project's extension. Core CIDR functionality comes from the original MoonCIDR Audit base; see provenance.

    #Commands and exit status

    CommandPurpose
    security CONFIGScan configuration security patterns, with evidence and remediation
    contexts CONFIGList structural selectors and effective rule origins
    audit CONFIGProduce findings and apply a release gate
    probe CONFIG IP --context IDExplain one IPv4 address decision
    validate CONFIGCheck the supported configuration and its dependencies
    request CONFIG IP --host HOST --uri PATHResolve a request and explain its address decision
    diff BEFORE AFTER --host HOST --uri PATHCompare address decisions, not configuration text
    expect CONFIG CIDR --expect allow\|deny --host HOST --uri PATHRequire the outcome for every address in a subnet

    Use COMMAND --help without preparing a configuration. --strict makes security/audit warnings fail the gate. Put -- before literal filenames beginning with -.

    StatusMeaning
    0Completed within the declared scope
    1Audit, diff or subnet expectation gate rejected the result
    2Invalid argument, file, encoding, syntax or include input
    3Unsupported or incomplete analysis
    4Resource budget exhausted

    A probe reports allowed_by_rule, denied_by_rule, or no_address_restriction. These describe the address module, not full request authorization. A denied address still counts as a successfully completed probe.

    CONFIG is relative to --root (default .). Relative includes are anchored to the main configuration's directory and must stay within that directory or its children. Filename */? masks are supported; absolute includes, parent traversal, linked input roots, symlinks and junctions are rejected.

    #MoonBit library and development

    The pure library opens no files, starts no processes and uses no network. The fileio and cmd/nginx-cli packages provide the separate Node.js boundary. Run the included MoonBit consumer example:

    moon update moon run examples/nginx --target wasm-gc moon run examples/regression --target wasm-gc

    The analysis API is in nginx/pkg.generated.mbti, including analyze_nginx_sources, Analysis::audits, AccessContext::probe and render_sarif, scan_security_sources, render_security, Analysis::resolve, compare_access and expect_access. The original IPv4/CIDR APIs remain in the root package. To use the 0.5.0 Mooncakes module from another MoonBit project, add the dependency and import its nginx package:

    moon add BeiLaDuo/moonnginx-access-audit@0.5.0

    import { "BeiLaDuo/moonnginx-access-audit/nginx" @adapter, }

    Build with moonc 0.10.21 or newer (MoonBit installation), Node.js 22.13+ and Python 3.10+. Version 0.5.0 uses the #derive syntax, verified with moonc v0.10.21+06da1ed44. CI enforces that compiler minimum. To build and verify from the source checkout:

    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-package

    When changing the CLI, refresh dist/moonnginx-access-audit.js from the release build before running distribution tests. Real Nginx comparison requires an external Nginx binary; see the Chinese guide. CI adds Linux native build/tests. Windows native compilation needs its own C toolchain and is not claimed by the local Windows verification.

    #Boundaries and maintenance

    The security scanner follows include-expanded directive contexts, including nested/regex locations and configurations containing TLS or authentication. This structural coverage does not imply full regex analysis, variable taint analysis or complete behavior regression. The rule matrix documents implemented checks and unsupported Gixy-Next capabilities. Dynamic variables/modules may require manual review; keep Nginx syntax and runtime tests.

    The regression router supports plaintext IPv4, exact host names, default servers and flat literal prefix/exact locations. It requires a normalized ASCII URI without a query or escapes. It refuses ambiguous regex/nested selection, unsupported listeners and selected auth/rewrite dependencies. The structural probe command still requires a context selector.

    Comparison is exact for the address module at one selected endpoint/URI and the declared IPv4 scope, not all paths or final HTTP authorization. It does not model IPv6, TLS/SNI, index/internal redirects, application logic or arbitrary third-party modules. Keep nginx -t, resource/response tests and deployment checks in your workflow. This library opens no sockets and changes no server configuration. See the precise profile.

    Development record, validation evidence, contribution guide, and security policy describe reproducible work and follow-up changes. Report ordinary defects with a minimal sanitized configuration; follow the security policy for sensitive cases.

    #License

    Apache-2.0. Redistribute the project NOTICE, third-party inventory, and retained upstream license/NOTICE files together with source or compiled deliveries. Competition submission, Mooncakes publication and GitHub releases are separate actions; this repository's development records do not imply they have occurred.

    AddressRange

    pub struct AddressRange {
    first : IPv4
    last : IPv4
    source_count : Int
    } derive(Eq,
    Debug
    )

    A closed IPv4 address interval.

    source_count records how many original intervals contributed to this range after union operations. It is useful when explaining why a range was produced, but does not change equality or containment semantics.

    AddressRange::address_count_label

    fn AddressRange::address_count_label(self : AddressRange) -> String

    AddressRange::contains_ip

    fn AddressRange::contains_ip(self : AddressRange, ip : IPv4) -> Bool

    AddressRange::contains_range

    fn AddressRange::contains_range(self : AddressRange, other : AddressRange) -> Bool

    AddressRange::equal

    AddressRange::first

    fn AddressRange::first(self : AddressRange) -> IPv4

    AddressRange::from_block

    fn AddressRange::from_block(block : CidrBlock) -> AddressRange

    AddressRange::last

    fn AddressRange::last(self : AddressRange) -> IPv4

    AddressRange::merge

    fn AddressRange::merge(self : AddressRange, other : AddressRange) -> Result[AddressRange, String]

    AddressRange::new

    fn AddressRange::new(first : IPv4, last : IPv4, source_count? : Int) -> Result[AddressRange, String]

    AddressRange::not_equal

    fn AddressRange::not_equal(x : AddressRange, y : AddressRange) -> Bool

    AddressRange::overlaps

    fn AddressRange::overlaps(self : AddressRange, other : AddressRange) -> Bool

    AddressRange::source_count

    fn AddressRange::source_count(self : AddressRange) -> Int

    AddressRange::summary

    fn AddressRange::summary(self : AddressRange) -> String

    AddressRange::to_string

    fn AddressRange::to_string(self : AddressRange) -> String

    AddressRange::touches

    fn AddressRange::touches(self : AddressRange, other : AddressRange) -> Bool

    AggregationReport

    pub struct AggregationReport {
    input_count : Int
    valid_count : Int
    duplicate_count : Int
    contained_count : Int
    merged_pair_count : Int
    blocks : Array[CidrBlock]
    errors : Array[String]
    } derive(
    Debug
    )

    Result of normalizing, deduplicating, and aggregating CIDR blocks.

    AggregationReport::blocks

    AggregationReport::changed

    fn AggregationReport::changed(self : AggregationReport) -> Bool

    AggregationReport::contained_count

    fn AggregationReport::contained_count(self : AggregationReport) -> Int

    AggregationReport::duplicate_count

    fn AggregationReport::duplicate_count(self : AggregationReport) -> Int

    AggregationReport::errors

    fn AggregationReport::errors(self : AggregationReport) -> Array[String]

    AggregationReport::input_count

    fn AggregationReport::input_count(self : AggregationReport) -> Int

    AggregationReport::merged_pair_count

    fn AggregationReport::merged_pair_count(self : AggregationReport) -> Int

    AggregationReport::output_count

    fn AggregationReport::output_count(self : AggregationReport) -> Int

    AggregationReport::reduction_count

    fn AggregationReport::reduction_count(self : AggregationReport) -> Int

    AggregationReport::summary

    fn AggregationReport::summary(self : AggregationReport) -> String

    AggregationReport::text_report

    fn AggregationReport::text_report(self : AggregationReport) -> String

    AggregationReport::valid_count

    fn AggregationReport::valid_count(self : AggregationReport) -> Int

    AuditPolicy

    pub struct AuditPolicy {
    wide_allow_prefix : Int
    flag_private : Bool
    flag_special_ranges : Bool
    flag_non_canonical : Bool
    flag_redundant_overlap : Bool
    } derive(Eq,
    Debug
    )

    Controls how noisy or strict CIDR audits should be.

    AuditPolicy::equal

    fn AuditPolicy::equal(AuditPolicy, AuditPolicy) -> Bool

    AuditPolicy::flag_non_canonical

    fn AuditPolicy::flag_non_canonical(self : AuditPolicy) -> Bool

    AuditPolicy::flag_private

    fn AuditPolicy::flag_private(self : AuditPolicy) -> Bool

    AuditPolicy::flag_redundant_overlap

    fn AuditPolicy::flag_redundant_overlap(self : AuditPolicy) -> Bool

    AuditPolicy::flag_special_ranges

    fn AuditPolicy::flag_special_ranges(self : AuditPolicy) -> Bool

    AuditPolicy::gateway

    fn AuditPolicy::gateway() -> AuditPolicy

    AuditPolicy::not_equal

    fn AuditPolicy::not_equal(x : AuditPolicy, y : AuditPolicy) -> Bool

    AuditPolicy::quiet

    fn AuditPolicy::quiet() -> AuditPolicy

    AuditPolicy::strict

    fn AuditPolicy::strict() -> AuditPolicy

    AuditPolicy::wide_allow_prefix

    fn AuditPolicy::wide_allow_prefix(self : AuditPolicy) -> Int

    AuditReport

    pub struct AuditReport {
    rules : Array[Rule]
    findings : Array[Finding]
    parse_errors : Array[String]
    } derive(
    Debug
    )

    AuditReport::count_hint_kind

    fn AuditReport::count_hint_kind(self : AuditReport, kind : HintKind) -> Int

    AuditReport::count_kind

    fn AuditReport::count_kind(self : AuditReport, kind : FindingKind) -> Int

    AuditReport::count_severity

    fn AuditReport::count_severity(self : AuditReport, severity : Severity) -> Int

    AuditReport::critical_count

    fn AuditReport::critical_count(self : AuditReport) -> Int

    AuditReport::evaluate_gate

    fn AuditReport::evaluate_gate(self : AuditReport, policy : GatePolicy) -> GateResult

    AuditReport::finding_count

    fn AuditReport::finding_count(self : AuditReport) -> Int

    AuditReport::findings

    fn AuditReport::findings(self : AuditReport) -> Array[Finding]

    AuditReport::fix_hints

    fn AuditReport::fix_hints(self : AuditReport) -> Array[FixHint]

    AuditReport::hint_report

    fn AuditReport::hint_report(self : AuditReport) -> String

    AuditReport::info_count

    fn AuditReport::info_count(self : AuditReport) -> Int

    AuditReport::json_report

    fn AuditReport::json_report(self : AuditReport) -> String

    Builds a stable JSON-like report without external dependencies.

    AuditReport::parse_errors

    fn AuditReport::parse_errors(self : AuditReport) -> Array[String]

    AuditReport::recommended_action

    fn AuditReport::recommended_action(self : AuditReport) -> String

    AuditReport::risk_level

    fn AuditReport::risk_level(self : AuditReport) -> String

    AuditReport::risk_score

    fn AuditReport::risk_score(self : AuditReport) -> Int

    AuditReport::rules

    fn AuditReport::rules(self : AuditReport) -> Array[Rule]

    AuditReport::summary_table

    fn AuditReport::summary_table(self : AuditReport) -> String

    AuditReport::text_report

    fn AuditReport::text_report(self : AuditReport) -> String

    Builds a compact human-readable audit report.

    AuditReport::warning_count

    fn AuditReport::warning_count(self : AuditReport) -> Int

    CidrBlock

    pub struct CidrBlock {
    network : IPv4
    prefix : Int
    } derive(Eq,
    Debug
    )

    A normalized IPv4 CIDR block.

    CidrBlock::broadcast

    fn CidrBlock::broadcast(self : CidrBlock) -> IPv4

    CidrBlock::contains_block

    fn CidrBlock::contains_block(self : CidrBlock, other : CidrBlock) -> Bool

    CidrBlock::contains_ip

    fn CidrBlock::contains_ip(self : CidrBlock, ip : IPv4) -> Bool

    CidrBlock::equal

    fn CidrBlock::equal(CidrBlock, CidrBlock) -> Bool

    CidrBlock::equal_range

    fn CidrBlock::equal_range(self : CidrBlock, other : CidrBlock) -> Bool

    CidrBlock::has_host_bits

    fn CidrBlock::has_host_bits(input : String) -> Bool

    CidrBlock::network

    fn CidrBlock::network(self : CidrBlock) -> IPv4

    CidrBlock::new

    fn CidrBlock::new(address : IPv4, prefix : Int) -> Result[CidrBlock, String]

    CidrBlock::new_unchecked

    fn CidrBlock::new_unchecked(network : IPv4, prefix : Int) -> CidrBlock

    CidrBlock::not_equal

    fn CidrBlock::not_equal(x : CidrBlock, y : CidrBlock) -> Bool

    CidrBlock::overlaps

    fn CidrBlock::overlaps(self : CidrBlock, other : CidrBlock) -> Bool

    CidrBlock::parse

    fn CidrBlock::parse(input : String) -> Result[CidrBlock, String]

    CidrBlock::parse_raw

    fn CidrBlock::parse_raw(input : String) -> Result[(IPv4, Int), String]

    CidrBlock::prefix

    fn CidrBlock::prefix(self : CidrBlock) -> Int

    CidrBlock::size_label

    fn CidrBlock::size_label(self : CidrBlock) -> String

    CidrBlock::to_string

    fn CidrBlock::to_string(self : CidrBlock) -> String

    CoverageStats

    pub struct CoverageStats {
    total_rules : Int
    allow_rules : Int
    deny_rules : Int
    private_rules : Int
    public_rules : Int
    special_rules : Int
    widest_prefix : Int
    narrowest_prefix : Int
    } derive(Eq,
    Debug
    )

    Aggregate facts about a rule set.

    CoverageStats::allow_rules

    fn CoverageStats::allow_rules(self : CoverageStats) -> Int

    CoverageStats::deny_rules

    fn CoverageStats::deny_rules(self : CoverageStats) -> Int

    CoverageStats::equal

    CoverageStats::narrowest_prefix

    fn CoverageStats::narrowest_prefix(self : CoverageStats) -> Int

    CoverageStats::not_equal

    fn CoverageStats::not_equal(x : CoverageStats, y : CoverageStats) -> Bool

    CoverageStats::private_rules

    fn CoverageStats::private_rules(self : CoverageStats) -> Int

    CoverageStats::public_rules

    fn CoverageStats::public_rules(self : CoverageStats) -> Int

    CoverageStats::special_rules

    fn CoverageStats::special_rules(self : CoverageStats) -> Int

    CoverageStats::summary

    fn CoverageStats::summary(self : CoverageStats) -> String

    CoverageStats::total_rules

    fn CoverageStats::total_rules(self : CoverageStats) -> Int

    CoverageStats::widest_prefix

    fn CoverageStats::widest_prefix(self : CoverageStats) -> Int

    Decision

    pub struct Decision {
    matched : Bool
    action : RuleAction
    rule_id : String
    block : String
    } derive(Eq,
    Debug
    )

    Decision::action

    fn Decision::action(self : Decision) -> RuleAction

    Decision::block

    fn Decision::block(self : Decision) -> String

    Decision::equal

    fn Decision::equal(Decision, Decision) -> Bool

    Decision::matched

    fn Decision::matched(self : Decision) -> Bool

    Decision::not_equal

    fn Decision::not_equal(x : Decision, y : Decision) -> Bool

    Decision::rule_id

    fn Decision::rule_id(self : Decision) -> String

    Decision::summary

    fn Decision::summary(self : Decision) -> String

    Decision::to_repr

    DiffReport

    pub struct DiffReport {
    changes : Array[RuleChange]
    } derive(
    Debug
    )

    DiffReport::change_count

    fn DiffReport::change_count(self : DiffReport) -> Int

    DiffReport::changes

    fn DiffReport::changes(self : DiffReport) -> Array[RuleChange]

    DiffReport::count_kind

    fn DiffReport::count_kind(self : DiffReport, kind : RuleChangeKind) -> Int

    DiffReport::is_empty

    fn DiffReport::is_empty(self : DiffReport) -> Bool

    DiffReport::risk_level

    fn DiffReport::risk_level(self : DiffReport) -> String

    DiffReport::risky_count

    fn DiffReport::risky_count(self : DiffReport) -> Int

    DiffReport::text_report

    fn DiffReport::text_report(self : DiffReport) -> String

    Finding

    pub struct Finding {
    kind : FindingKind
    severity : Severity
    rule_id : String
    related_rule_id : String
    message : String
    } derive(Eq,
    Debug
    )

    Finding::equal

    fn Finding::equal(Finding, Finding) -> Bool

    Finding::kind

    fn Finding::kind(self : Finding) -> FindingKind

    Finding::message

    fn Finding::message(self : Finding) -> String

    Finding::new

    fn Finding::new(kind : FindingKind, severity : Severity, rule_id : String, message : String, related_rule_id? : String) -> Finding

    Finding::not_equal

    fn Finding::not_equal(x : Finding, y : Finding) -> Bool

    Finding::related_rule_id

    fn Finding::related_rule_id(self : Finding) -> String

    Finding::rule_id

    fn Finding::rule_id(self : Finding) -> String

    Finding::severity

    fn Finding::severity(self : Finding) -> Severity

    Finding::to_repr

    FindingKind

    pub(all) enum FindingKind {
    DuplicateRule
    ShadowedRule
    ConflictingOverlap
    RedundantOverlap
    TooWideAllow
    GlobalDeny
    PrivateRange
    LoopbackRange
    LinkLocalRange
    MulticastRange
    NonCanonicalCidr
    ParseError
    } derive(Eq,
    Debug
    )

    Classifies why a rule deserves attention.

    FindingKind::equal

    fn FindingKind::equal(FindingKind, FindingKind) -> Bool

    FindingKind::label

    fn FindingKind::label(self : FindingKind) -> String

    FindingKind::not_equal

    fn FindingKind::not_equal(x : FindingKind, y : FindingKind) -> Bool

    FixHint

    pub struct FixHint {
    kind : HintKind
    severity : Severity
    rule_id : String
    text : String
    } derive(Eq,
    Debug
    )

    FixHint::equal

    fn FixHint::equal(FixHint, FixHint) -> Bool

    FixHint::kind

    fn FixHint::kind(self : FixHint) -> HintKind

    FixHint::new

    fn FixHint::new(kind : HintKind, severity : Severity, rule_id : String, text : String) -> FixHint

    FixHint::not_equal

    fn FixHint::not_equal(x : FixHint, y : FixHint) -> Bool

    FixHint::rule_id

    fn FixHint::rule_id(self : FixHint) -> String

    FixHint::severity

    fn FixHint::severity(self : FixHint) -> Severity

    FixHint::summary

    fn FixHint::summary(self : FixHint) -> String

    FixHint::text

    fn FixHint::text(self : FixHint) -> String

    FixHint::to_repr

    GatePolicy

    pub struct GatePolicy {
    name : String
    max_critical : Int
    max_warning : Int
    max_risk_score : Int
    allow_parse_errors : Bool
    } derive(Eq,
    Debug
    )

    Thresholds used to decide whether a rule set may pass a CI or release gate.

    GatePolicy::allow_parse_errors

    fn GatePolicy::allow_parse_errors(self : GatePolicy) -> Bool

    GatePolicy::development

    fn GatePolicy::development() -> GatePolicy

    Development policy: blocks only very risky reports and parse failures.

    GatePolicy::equal

    fn GatePolicy::equal(GatePolicy, GatePolicy) -> Bool

    GatePolicy::max_critical

    fn GatePolicy::max_critical(self : GatePolicy) -> Int

    GatePolicy::max_risk_score

    fn GatePolicy::max_risk_score(self : GatePolicy) -> Int

    GatePolicy::max_warning

    fn GatePolicy::max_warning(self : GatePolicy) -> Int

    GatePolicy::name

    fn GatePolicy::name(self : GatePolicy) -> String

    GatePolicy::new

    fn GatePolicy::new(name : String, max_critical : Int, max_warning : Int, max_risk_score : Int, allow_parse_errors? : Bool) -> Result[GatePolicy, String]

    GatePolicy::not_equal

    fn GatePolicy::not_equal(x : GatePolicy, y : GatePolicy) -> Bool

    GatePolicy::release

    fn GatePolicy::release() -> GatePolicy

    Strict release policy: no critical findings, warnings, or parse errors.

    GatePolicy::review

    fn GatePolicy::review() -> GatePolicy

    Review policy: allows a small warning budget but no critical findings.

    GatePolicy::summary

    fn GatePolicy::summary(self : GatePolicy) -> String

    GateReason

    pub struct GateReason {
    code : String
    actual : Int
    limit : Int
    message : String
    } derive(Eq,
    Debug
    )

    GateReason::actual

    fn GateReason::actual(self : GateReason) -> Int

    GateReason::code

    fn GateReason::code(self : GateReason) -> String

    GateReason::equal

    fn GateReason::equal(GateReason, GateReason) -> Bool

    GateReason::limit

    fn GateReason::limit(self : GateReason) -> Int

    GateReason::message

    fn GateReason::message(self : GateReason) -> String

    GateReason::new

    fn GateReason::new(code : String, actual : Int, limit : Int, message : String) -> GateReason

    GateReason::not_equal

    fn GateReason::not_equal(x : GateReason, y : GateReason) -> Bool

    GateReason::summary

    fn GateReason::summary(self : GateReason) -> String

    GateResult

    pub struct GateResult {
    policy : GatePolicy
    passed : Bool
    risk_score : Int
    reasons : Array[GateReason]
    } derive(
    Debug
    )

    GateResult::decision

    fn GateResult::decision(self : GateResult) -> String

    GateResult::has_reason

    fn GateResult::has_reason(self : GateResult, code : String) -> Bool

    GateResult::passed

    fn GateResult::passed(self : GateResult) -> Bool

    GateResult::policy

    fn GateResult::policy(self : GateResult) -> GatePolicy

    GateResult::reason_count

    fn GateResult::reason_count(self : GateResult) -> Int

    GateResult::reasons

    fn GateResult::reasons(self : GateResult) -> Array[GateReason]

    GateResult::risk_score

    fn GateResult::risk_score(self : GateResult) -> Int

    GateResult::text_report

    fn GateResult::text_report(self : GateResult) -> String

    HintKind

    pub(all) enum HintKind {
    MoveSpecificRule
    TightenCidr
    ConfirmDefaultPolicy
    CanonicalizeInput
    RemoveDuplicate
    ReviewSpecialScope
    FixSyntax
    ReviewOverlap
    } derive(Eq,
    Debug
    )

    Category of remediation hint produced from audit findings.

    HintKind::equal

    fn HintKind::equal(HintKind, HintKind) -> Bool

    HintKind::label

    fn HintKind::label(self : HintKind) -> String

    HintKind::not_equal

    fn HintKind::not_equal(x : HintKind, y : HintKind) -> Bool

    HintKind::to_repr

    IPv4

    pub struct IPv4 {
    value : UInt
    } derive(Eq,
    Debug
    )

    A parsed IPv4 address stored as an unsigned 32-bit integer.

    IPv4::equal

    fn IPv4::equal(IPv4, IPv4) -> Bool

    IPv4::is_limited_broadcast

    fn IPv4::is_limited_broadcast(self : IPv4) -> Bool

    fn IPv4::is_link_local(self : IPv4) -> Bool

    IPv4::is_loopback

    fn IPv4::is_loopback(self : IPv4) -> Bool

    IPv4::is_multicast

    fn IPv4::is_multicast(self : IPv4) -> Bool

    IPv4::is_private

    fn IPv4::is_private(self : IPv4) -> Bool

    IPv4::is_public

    fn IPv4::is_public(self : IPv4) -> Bool

    Returns true when the address is not one of the private or special scopes currently recognized by this package.

    IPv4::is_unspecified

    fn IPv4::is_unspecified(self : IPv4) -> Bool

    IPv4::new

    fn IPv4::new(value : UInt) -> IPv4

    IPv4::not_equal

    fn IPv4::not_equal(x : IPv4, y : IPv4) -> Bool

    IPv4::parse

    fn IPv4::parse(input : String) -> Result[IPv4, String]

    IPv4::scope_label

    fn IPv4::scope_label(self : IPv4) -> String

    IPv4::to_dotted

    fn IPv4::to_dotted(self : IPv4) -> String

    IPv4::to_repr

    IPv4::value

    fn IPv4::value(self : IPv4) -> UInt

    ImportFormat

    pub(all) enum ImportFormat {
    PlainRules
    NginxAccess
    CsvRules
    } derive(Eq,
    Debug
    )

    Input syntax understood by the configuration import layer.

    ImportFormat::equal

    ImportFormat::label

    fn ImportFormat::label(self : ImportFormat) -> String

    ImportFormat::not_equal

    fn ImportFormat::not_equal(x : ImportFormat, y : ImportFormat) -> Bool

    ImportIssue

    pub struct ImportIssue {
    line : Int
    level : ImportIssueLevel
    code : String
    message : String
    input : String
    } derive(Eq,
    Debug
    )

    ImportIssue::code

    fn ImportIssue::code(self : ImportIssue) -> String

    ImportIssue::equal

    fn ImportIssue::equal(ImportIssue, ImportIssue) -> Bool

    ImportIssue::input

    fn ImportIssue::input(self : ImportIssue) -> String

    ImportIssue::level

    ImportIssue::line

    fn ImportIssue::line(self : ImportIssue) -> Int

    ImportIssue::message

    fn ImportIssue::message(self : ImportIssue) -> String

    ImportIssue::new

    fn ImportIssue::new(line : Int, level : ImportIssueLevel, code : String, message : String, input : String) -> ImportIssue

    ImportIssue::not_equal

    fn ImportIssue::not_equal(x : ImportIssue, y : ImportIssue) -> Bool

    ImportIssue::summary

    fn ImportIssue::summary(self : ImportIssue) -> String

    ImportIssueLevel

    pub(all) enum ImportIssueLevel {
    ImportWarning
    ImportError
    } derive(Eq,
    Debug
    )

    ImportIssueLevel::equal

    ImportIssueLevel::label

    fn ImportIssueLevel::label(self : ImportIssueLevel) -> String

    ImportIssueLevel::not_equal

    fn ImportIssueLevel::not_equal(x : ImportIssueLevel, y : ImportIssueLevel) -> Bool

    ImportReport

    pub struct ImportReport {
    format : ImportFormat
    source_count : Int
    rules : Array[Rule]
    issues : Array[ImportIssue]
    } derive(
    Debug
    )

    ImportReport::accepted_count

    fn ImportReport::accepted_count(self : ImportReport) -> Int

    ImportReport::can_audit

    fn ImportReport::can_audit(self : ImportReport) -> Bool

    ImportReport::error_count

    fn ImportReport::error_count(self : ImportReport) -> Int

    ImportReport::format

    fn ImportReport::format(self : ImportReport) -> ImportFormat

    ImportReport::is_clean

    fn ImportReport::is_clean(self : ImportReport) -> Bool

    ImportReport::issues

    ImportReport::rules

    fn ImportReport::rules(self : ImportReport) -> Array[Rule]

    ImportReport::source_count

    fn ImportReport::source_count(self : ImportReport) -> Int

    ImportReport::summary

    fn ImportReport::summary(self : ImportReport) -> String

    ImportReport::text_report

    fn ImportReport::text_report(self : ImportReport) -> String

    ImportReport::to_ruleset

    fn ImportReport::to_ruleset(self : ImportReport) -> RuleSet

    ImportReport::warning_count

    fn ImportReport::warning_count(self : ImportReport) -> Int

    Rule

    pub struct Rule {
    id : String
    action : RuleAction
    block : CidrBlock
    source_block : String
    note : String
    } derive(Eq,
    Debug
    )

    A single ordered firewall, proxy, or gateway rule.

    Rule::action

    fn Rule::action(self : Rule) -> RuleAction

    Rule::block

    fn Rule::block(self : Rule) -> CidrBlock

    Rule::equal

    fn Rule::equal(Rule, Rule) -> Bool

    Rule::id

    fn Rule::id(self : Rule) -> String

    Rule::is_canonical

    fn Rule::is_canonical(self : Rule) -> Bool

    Rule::matches

    fn Rule::matches(self : Rule, ip : IPv4) -> Bool

    Rule::new

    fn Rule::new(id : String, action : RuleAction, block : CidrBlock, source_block? : String, note? : String) -> Rule

    Rule::not_equal

    fn Rule::not_equal(x : Rule, y : Rule) -> Bool

    Rule::note

    fn Rule::note(self : Rule) -> String

    Rule::parse

    fn Rule::parse(id : String, line : String) -> Result[Rule, String]

    Rule::same_decision

    fn Rule::same_decision(self : Rule, other : Rule) -> Bool

    Rule::source_block

    fn Rule::source_block(self : Rule) -> String

    Rule::summary

    fn Rule::summary(self : Rule) -> String

    Rule::to_repr

    RuleAction

    pub(all) enum RuleAction {
    Allow
    Deny
    } derive(Eq,
    Debug
    )

    Action taken when a CIDR rule matches.

    RuleAction::equal

    fn RuleAction::equal(RuleAction, RuleAction) -> Bool

    RuleAction::label

    fn RuleAction::label(self : RuleAction) -> String

    RuleAction::not_equal

    fn RuleAction::not_equal(x : RuleAction, y : RuleAction) -> Bool

    RuleAction::parse

    fn RuleAction::parse(input : String) -> Result[RuleAction, String]

    RuleChange

    pub struct RuleChange {
    kind : RuleChangeKind
    before_id : String
    after_id : String
    block : String
    message : String
    } derive(Eq,
    Debug
    )

    A change item matched by CIDR range.

    RuleChange::after_id

    fn RuleChange::after_id(self : RuleChange) -> String

    RuleChange::before_id

    fn RuleChange::before_id(self : RuleChange) -> String

    RuleChange::block

    fn RuleChange::block(self : RuleChange) -> String

    RuleChange::equal

    fn RuleChange::equal(RuleChange, RuleChange) -> Bool

    RuleChange::kind

    RuleChange::message

    fn RuleChange::message(self : RuleChange) -> String

    RuleChange::new

    fn RuleChange::new(kind : RuleChangeKind, before_id : String, after_id : String, block : String, message : String) -> RuleChange

    RuleChange::not_equal

    fn RuleChange::not_equal(x : RuleChange, y : RuleChange) -> Bool

    RuleChange::summary

    fn RuleChange::summary(self : RuleChange) -> String

    RuleChangeKind

    pub(all) enum RuleChangeKind {
    AddedRule
    RemovedRule
    ActionChanged
    NoteChanged
    UnchangedRule
    } derive(Eq,
    Debug
    )

    Type of change between two rule sets.

    RuleChangeKind::equal

    RuleChangeKind::is_risky

    fn RuleChangeKind::is_risky(self : RuleChangeKind) -> Bool

    RuleChangeKind::label

    fn RuleChangeKind::label(self : RuleChangeKind) -> String

    RuleChangeKind::not_equal

    fn RuleChangeKind::not_equal(x : RuleChangeKind, y : RuleChangeKind) -> Bool

    RuleSet

    pub struct RuleSet {
    rules : Array[Rule]
    parse_errors : Array[String]
    } derive(
    Debug
    )

    RuleSet::audit

    fn RuleSet::audit(self : RuleSet) -> AuditReport

    RuleSet::audit_with_policy

    fn RuleSet::audit_with_policy(self : RuleSet, policy : AuditPolicy) -> AuditReport

    RuleSet::coverage_ranges

    fn RuleSet::coverage_ranges(self : RuleSet, action : RuleAction) -> Array[AddressRange]

    Returns the union of all rule blocks with the requested action.

    This is a structural view. Ordered first-match behavior is intentionally handled separately by RuleSet::decide.

    RuleSet::coverage_report

    fn RuleSet::coverage_report(self : RuleSet, action : RuleAction, target : CidrBlock) -> String

    RuleSet::coverage_stats

    fn RuleSet::coverage_stats(self : RuleSet) -> CoverageStats

    RuleSet::decide

    fn RuleSet::decide(self : RuleSet, ip : IPv4) -> Decision

    RuleSet::diff_from

    fn RuleSet::diff_from(self : RuleSet, previous : RuleSet) -> DiffReport

    RuleSet::evaluate_gate

    fn RuleSet::evaluate_gate(self : RuleSet, audit_policy : AuditPolicy, gate_policy : GatePolicy) -> GateResult

    RuleSet::explain_ip

    fn RuleSet::explain_ip(self : RuleSet, ip : IPv4) -> String

    RuleSet::explain_many

    fn RuleSet::explain_many(self : RuleSet, probes : Array[String]) -> String

    RuleSet::first_rule_for_block

    fn RuleSet::first_rule_for_block(self : RuleSet, block : CidrBlock) -> String

    RuleSet::from_lines

    fn RuleSet::from_lines(lines : Array[String]) -> RuleSet

    RuleSet::inventory_report

    fn RuleSet::inventory_report(self : RuleSet) -> String

    RuleSet::matching_rules

    fn RuleSet::matching_rules(self : RuleSet, ip : IPv4) -> Array[Rule]

    RuleSet::new

    fn RuleSet::new(rules : Array[Rule]) -> RuleSet

    RuleSet::parse_errors

    fn RuleSet::parse_errors(self : RuleSet) -> Array[String]

    RuleSet::rules

    fn RuleSet::rules(self : RuleSet) -> Array[Rule]

    RuleSet::to_repr

    Severity

    pub(all) enum Severity {
    Info
    Warning
    Critical
    } derive(Eq,
    Debug
    )

    Severity assigned to an audit finding.

    Severity::equal

    fn Severity::equal(Severity, Severity) -> Bool

    Severity::label

    fn Severity::label(self : Severity) -> String

    Severity::not_equal

    fn Severity::not_equal(x : Severity, y : Severity) -> Bool

    Severity::score

    fn Severity::score(self : Severity) -> Int

    Severity::to_repr

    aggregate_blocks

    fn aggregate_blocks(blocks : Array[CidrBlock]) -> AggregationReport

    Aggregates already parsed CIDR blocks.

    aggregate_cidr_strings

    fn aggregate_cidr_strings(inputs : Array[String]) -> AggregationReport

    Parses and aggregates a list of CIDR strings.

    Invalid entries are preserved in errors rather than aborting the whole operation, making the API suitable for configuration linting.

    audit_rules

    fn audit_rules(rules : Array[Rule]) -> AuditReport

    audit_rules_with_policy

    fn audit_rules_with_policy(rules : Array[Rule], policy : AuditPolicy) -> AuditReport

    clip_ranges_to_block

    fn clip_ranges_to_block(target : CidrBlock, coverage : Array[AddressRange]) -> Array[AddressRange]

    Clips address ranges to a target CIDR and returns a merged union.

    diff_rule_sets

    fn diff_rule_sets(current : RuleSet, previous : RuleSet) -> DiffReport

    import_csv_rules

    fn import_csv_rules(lines : Array[String]) -> ImportReport

    Imports rows in action,cidr,note form.

    A header row is optional. Quoted fields, embedded commas, and doubled quote escapes are supported. Extra columns are folded into the note and reported as a warning so information is not silently discarded.

    import_nginx_access

    fn import_nginx_access(lines : Array[String]) -> ImportReport

    Imports Nginx access directives such as allow 10.0.0.0/8;.

    deny all; and allow all; are converted to 0.0.0.0/0. Other Nginx directives are rejected so accidental input from an unrelated section is visible to the caller.

    import_plain_rules

    fn import_plain_rules(lines : Array[String]) -> ImportReport

    Imports the native compact syntax: allow 10.0.0.0/8 note.

    merge_address_ranges

    fn merge_address_ranges(input : Array[AddressRange]) -> Array[AddressRange]

    Sorts and merges overlapping or adjacent address ranges.

    parse_rules

    fn parse_rules(lines : Array[String]) -> RuleSet

    ranges_from_blocks

    fn ranges_from_blocks(blocks : Array[CidrBlock]) -> Array[AddressRange]

    Converts CIDR blocks into a sorted, non-overlapping union of address ranges.

    uncovered_ranges

    fn uncovered_ranges(target : CidrBlock, coverage : Array[AddressRange]) -> Array[AddressRange]

    Finds holes inside target that are not covered by any supplied range.