noir-alibi 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- noir_alibi-0.1.0/.github/workflows/ci.yml +45 -0
- noir_alibi-0.1.0/.github/workflows/noir.yml +79 -0
- noir_alibi-0.1.0/.github/workflows/release.yml +107 -0
- noir_alibi-0.1.0/.gitignore +13 -0
- noir_alibi-0.1.0/CHANGELOG.md +53 -0
- noir_alibi-0.1.0/CONTRIBUTING.md +47 -0
- noir_alibi-0.1.0/LICENSE +21 -0
- noir_alibi-0.1.0/PKG-INFO +317 -0
- noir_alibi-0.1.0/README.md +297 -0
- noir_alibi-0.1.0/SECURITY.md +32 -0
- noir_alibi-0.1.0/pyproject.toml +63 -0
- noir_alibi-0.1.0/src/alibi/__init__.py +10 -0
- noir_alibi-0.1.0/src/alibi/cli.py +216 -0
- noir_alibi-0.1.0/src/alibi/collect.py +334 -0
- noir_alibi-0.1.0/src/alibi/cover.py +142 -0
- noir_alibi-0.1.0/src/alibi/ignore.py +108 -0
- noir_alibi-0.1.0/src/alibi/index.py +432 -0
- noir_alibi-0.1.0/src/alibi/normalize.py +356 -0
- noir_alibi-0.1.0/src/alibi/report/__init__.py +0 -0
- noir_alibi-0.1.0/src/alibi/report/history.py +116 -0
- noir_alibi-0.1.0/src/alibi/report/json_report.py +126 -0
- noir_alibi-0.1.0/src/alibi/report/sarif.py +360 -0
- noir_alibi-0.1.0/src/alibi/report/text.py +448 -0
- noir_alibi-0.1.0/src/alibi/rules.py +368 -0
- noir_alibi-0.1.0/src/alibi/rules.yml +199 -0
- noir_alibi-0.1.0/src/alibi/scope.py +204 -0
- noir_alibi-0.1.0/src/alibi/snapshot.py +426 -0
- noir_alibi-0.1.0/src/alibi/views.py +99 -0
- noir_alibi-0.1.0/src/alibi/views.yml +103 -0
- noir_alibi-0.1.0/tests/conftest.py +28 -0
- noir_alibi-0.1.0/tests/fixtures/five_views/app/main.py +23 -0
- noir_alibi-0.1.0/tests/fixtures/five_views/captures/prod.har +113 -0
- noir_alibi-0.1.0/tests/fixtures/five_views/contracts/openapi.yaml +9 -0
- noir_alibi-0.1.0/tests/fixtures/five_views/gateway/nginx.conf +12 -0
- noir_alibi-0.1.0/tests/fixtures/five_views/infra/main.tf +17 -0
- noir_alibi-0.1.0/tests/fixtures/matched/app/main.py +18 -0
- noir_alibi-0.1.0/tests/fixtures/matched/contracts/openapi.yaml +23 -0
- noir_alibi-0.1.0/tests/fixtures/sarif-schema-2.1.0.json +3389 -0
- noir_alibi-0.1.0/tests/test_collect.py +173 -0
- noir_alibi-0.1.0/tests/test_cover.py +51 -0
- noir_alibi-0.1.0/tests/test_end_to_end.py +183 -0
- noir_alibi-0.1.0/tests/test_ignore.py +80 -0
- noir_alibi-0.1.0/tests/test_index.py +371 -0
- noir_alibi-0.1.0/tests/test_normalize.py +211 -0
- noir_alibi-0.1.0/tests/test_report_text.py +145 -0
- noir_alibi-0.1.0/tests/test_rules.py +465 -0
- noir_alibi-0.1.0/tests/test_sarif.py +453 -0
- noir_alibi-0.1.0/tests/test_scope.py +152 -0
- noir_alibi-0.1.0/tests/test_snapshot.py +409 -0
- noir_alibi-0.1.0/tests/test_views.py +47 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
# The floor and the current release. Between them sit the features this
|
|
14
|
+
# codebase actually uses; anything that breaks on one and not the other
|
|
15
|
+
# is a version assumption worth catching here rather than in a report.
|
|
16
|
+
python: ["3.11", "3.13"]
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
|
|
23
|
+
- name: Install
|
|
24
|
+
run: |
|
|
25
|
+
uv venv --python ${{ matrix.python }}
|
|
26
|
+
uv pip install -e .
|
|
27
|
+
# The dev group, not just pytest: jsonschema is what holds the SARIF
|
|
28
|
+
# report to the published 2.1.0 schema, and without it those tests
|
|
29
|
+
# skip themselves. A validation that quietly does not run is worse
|
|
30
|
+
# than none, because the badge still passes.
|
|
31
|
+
uv pip install --group dev
|
|
32
|
+
|
|
33
|
+
# Lint once, not once per Python version: ruff's findings do not depend
|
|
34
|
+
# on the interpreter running the tests.
|
|
35
|
+
- name: Lint
|
|
36
|
+
if: matrix.python == '3.13'
|
|
37
|
+
run: .venv/bin/python -m ruff check .
|
|
38
|
+
|
|
39
|
+
# Most of the suite runs without noir; the end-to-end tests skip
|
|
40
|
+
# themselves when it is absent, which is why it is not installed here,
|
|
41
|
+
# so a missing release never blocks a pull request. The integration
|
|
42
|
+
# against a real noir build runs in noir.yml, where a failure means
|
|
43
|
+
# "noir moved" rather than "this pull request is bad".
|
|
44
|
+
- name: Test
|
|
45
|
+
run: .venv/bin/python -m pytest tests/ -q
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# The one workflow that installs noir.
|
|
2
|
+
#
|
|
3
|
+
# ci.yml deliberately does not: the end-to-end tests skip themselves when noir
|
|
4
|
+
# is absent, so a pull request never waits on a noir release. The cost of that
|
|
5
|
+
# is a green badge which proves nothing about the only thing alibi does --
|
|
6
|
+
# read noir's JSON, its `list techs` catalog, and its tagger output. Every one
|
|
7
|
+
# of those is a contract with a program released on its own schedule, and it
|
|
8
|
+
# can break without a line of this repository changing.
|
|
9
|
+
#
|
|
10
|
+
# So the integration runs here instead, on a schedule, where a failure means
|
|
11
|
+
# "noir moved" rather than "this pull request is bad".
|
|
12
|
+
name: noir integration
|
|
13
|
+
|
|
14
|
+
on:
|
|
15
|
+
schedule:
|
|
16
|
+
- cron: "0 6 * * 1" # Monday morning UTC
|
|
17
|
+
workflow_dispatch:
|
|
18
|
+
inputs:
|
|
19
|
+
noir_version:
|
|
20
|
+
description: "noir version to test against (default: latest release)"
|
|
21
|
+
required: false
|
|
22
|
+
push:
|
|
23
|
+
paths:
|
|
24
|
+
# The files that encode assumptions about noir specifically.
|
|
25
|
+
- "src/alibi/collect.py"
|
|
26
|
+
- "src/alibi/views.yml"
|
|
27
|
+
- "tests/test_end_to_end.py"
|
|
28
|
+
- ".github/workflows/noir.yml"
|
|
29
|
+
|
|
30
|
+
jobs:
|
|
31
|
+
integration:
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
- uses: actions/checkout@v4
|
|
35
|
+
- uses: astral-sh/setup-uv@v5
|
|
36
|
+
|
|
37
|
+
# The linux asset is a bare executable named for its release
|
|
38
|
+
# (noir-v1.3.0-linux-x86_64), not an archive and not called `noir`.
|
|
39
|
+
- name: Install noir
|
|
40
|
+
env:
|
|
41
|
+
GH_TOKEN: ${{ github.token }}
|
|
42
|
+
PINNED: ${{ inputs.noir_version }}
|
|
43
|
+
run: |
|
|
44
|
+
tag="${PINNED:-$(gh release view --repo owasp-noir/noir --json tagName -q .tagName)}"
|
|
45
|
+
case "$tag" in v*) ;; *) tag="v$tag" ;; esac # accept 1.3.0 or v1.3.0
|
|
46
|
+
echo "noir $tag"
|
|
47
|
+
gh release download "$tag" --repo owasp-noir/noir \
|
|
48
|
+
--pattern '*-linux-x86_64' --dir /tmp/noir --clobber
|
|
49
|
+
binary=$(find /tmp/noir -maxdepth 1 -type f | head -1)
|
|
50
|
+
if [ -z "$binary" ]; then
|
|
51
|
+
echo "::error::noir $tag has no linux-x86_64 asset"
|
|
52
|
+
exit 1
|
|
53
|
+
fi
|
|
54
|
+
mkdir -p "$HOME/.local/bin"
|
|
55
|
+
install -m 0755 "$binary" "$HOME/.local/bin/noir"
|
|
56
|
+
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
|
57
|
+
"$HOME/.local/bin/noir" --version
|
|
58
|
+
|
|
59
|
+
- name: Install alibi
|
|
60
|
+
run: |
|
|
61
|
+
uv venv --python 3.13
|
|
62
|
+
uv pip install -e .
|
|
63
|
+
uv pip install --group dev
|
|
64
|
+
|
|
65
|
+
# -p no:randomly is not needed; what matters is that the noir-dependent
|
|
66
|
+
# tests are the point of this job, so a skip is a failure here.
|
|
67
|
+
- name: The end-to-end tests must run, not skip
|
|
68
|
+
run: |
|
|
69
|
+
.venv/bin/python -m pytest tests/ -q -rs
|
|
70
|
+
if .venv/bin/python -m pytest tests/test_end_to_end.py -q -rs 2>&1 | grep -q "noir is not installed"; then
|
|
71
|
+
echo "::error::end-to-end tests skipped -- noir was not found"
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
# The view map defaults anything unlisted to `code`, which is wrong for a
|
|
76
|
+
# specification analyzer noir added after views.yml was last touched.
|
|
77
|
+
# `doctor` exits non-zero on exactly that drift.
|
|
78
|
+
- name: The view map still matches this noir build
|
|
79
|
+
run: .venv/bin/alibi doctor
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ["v*"]
|
|
6
|
+
|
|
7
|
+
# Trusted Publishing rather than a stored API token: PyPI mints a short-lived
|
|
8
|
+
# credential from this workflow's OIDC identity, so there is no secret in the
|
|
9
|
+
# repository to leak or rotate. It needs a one-time publisher configured on
|
|
10
|
+
# PyPI for project `noir-alibi`, owner `owasp-noir`, repository `alibi`,
|
|
11
|
+
# workflow `release.yml`, environment `pypi`.
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
# The tag says what to publish; nothing checks that it matches the version in
|
|
17
|
+
# pyproject.toml. Tagging v0.2.0 with 0.1.0 still in the file uploads a second
|
|
18
|
+
# 0.1.0, and PyPI does not allow replacing a file once it is there. So the
|
|
19
|
+
# comparison happens before anything is built.
|
|
20
|
+
check:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- name: The tag and the packaged version have to agree
|
|
25
|
+
run: |
|
|
26
|
+
tagged="${GITHUB_REF_NAME#v}"
|
|
27
|
+
packaged=$(python -c "import tomllib,pathlib; print(tomllib.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])")
|
|
28
|
+
echo "tag: $tagged, pyproject: $packaged"
|
|
29
|
+
if [ "$tagged" != "$packaged" ]; then
|
|
30
|
+
echo "::error::tag v$tagged does not match pyproject.toml version $packaged"
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# The same suite CI runs on every pull request. A tag can be pushed to a
|
|
35
|
+
# commit that never had one, so it is not safe to assume this already passed.
|
|
36
|
+
test:
|
|
37
|
+
needs: check
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
strategy:
|
|
40
|
+
matrix:
|
|
41
|
+
python: ["3.11", "3.13"]
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
- uses: astral-sh/setup-uv@v5
|
|
45
|
+
- name: Install
|
|
46
|
+
run: |
|
|
47
|
+
uv venv --python ${{ matrix.python }}
|
|
48
|
+
uv pip install -e .
|
|
49
|
+
uv pip install --group dev
|
|
50
|
+
- run: .venv/bin/python -m pytest tests/ -q
|
|
51
|
+
|
|
52
|
+
build:
|
|
53
|
+
needs: test
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
steps:
|
|
56
|
+
- uses: actions/checkout@v4
|
|
57
|
+
- uses: astral-sh/setup-uv@v5
|
|
58
|
+
- run: uv build
|
|
59
|
+
# views.yml and rules.yml are data the tool cannot run without, and they
|
|
60
|
+
# reach the wheel only because hatchling includes non-Python files in the
|
|
61
|
+
# package directory by default. That is a default, not a declaration, so
|
|
62
|
+
# a wheel missing them would install cleanly and fail on first use.
|
|
63
|
+
- name: The wheel carries the data files
|
|
64
|
+
run: |
|
|
65
|
+
python -m zipfile -l dist/*.whl | tee /dev/stderr | grep -q 'alibi/views.yml'
|
|
66
|
+
python -m zipfile -l dist/*.whl | grep -q 'alibi/rules.yml'
|
|
67
|
+
- name: The built package installs and runs
|
|
68
|
+
run: |
|
|
69
|
+
python -m venv /tmp/check
|
|
70
|
+
/tmp/check/bin/pip install --quiet dist/*.whl
|
|
71
|
+
/tmp/check/bin/alibi --version
|
|
72
|
+
- uses: actions/upload-artifact@v4
|
|
73
|
+
with:
|
|
74
|
+
name: dist
|
|
75
|
+
path: dist/
|
|
76
|
+
|
|
77
|
+
publish:
|
|
78
|
+
needs: build
|
|
79
|
+
runs-on: ubuntu-latest
|
|
80
|
+
environment: pypi
|
|
81
|
+
permissions:
|
|
82
|
+
id-token: write # what PyPI exchanges for a publishing token
|
|
83
|
+
steps:
|
|
84
|
+
- uses: actions/download-artifact@v4
|
|
85
|
+
with:
|
|
86
|
+
name: dist
|
|
87
|
+
path: dist/
|
|
88
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
89
|
+
|
|
90
|
+
github_release:
|
|
91
|
+
needs: publish
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
permissions:
|
|
94
|
+
contents: write
|
|
95
|
+
steps:
|
|
96
|
+
- uses: actions/checkout@v4
|
|
97
|
+
- uses: actions/download-artifact@v4
|
|
98
|
+
with:
|
|
99
|
+
name: dist
|
|
100
|
+
path: dist/
|
|
101
|
+
- name: Draft the release from the changelog
|
|
102
|
+
env:
|
|
103
|
+
GH_TOKEN: ${{ github.token }}
|
|
104
|
+
run: |
|
|
105
|
+
gh release create "$GITHUB_REF_NAME" dist/* \
|
|
106
|
+
--title "$GITHUB_REF_NAME" \
|
|
107
|
+
--notes "See [CHANGELOG.md](https://github.com/${GITHUB_REPOSITORY}/blob/${GITHUB_REF_NAME}/CHANGELOG.md)."
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to alibi. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
|
+
[semantic versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-08-30
|
|
10
|
+
|
|
11
|
+
First release. Runs [noir](https://github.com/owasp-noir/noir) once per view,
|
|
12
|
+
joins the results, and reports the endpoints that no second view can account
|
|
13
|
+
for.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- `alibi scan` compares all five of noir's views -- code, doc, traffic,
|
|
18
|
+
gateway and infrastructure -- by scanning each source once per view with
|
|
19
|
+
`--only-techs`, so that endpoints two views agree on are not deduplicated
|
|
20
|
+
into one before they can be counted as corroboration.
|
|
21
|
+
- Eight rules over those views: `ORPHAN`, `LIVE_UNDOC`, `SHADOW`, `DANGLING`,
|
|
22
|
+
`DRIFT`, `PHANTOM`, `UNEXPOSED` and `COLD`. Severity then shifts on noir's
|
|
23
|
+
taggers -- personal data, file uploads, no sign of authentication, a method
|
|
24
|
+
that changes state.
|
|
25
|
+
- Path normalization across framework route syntaxes, on the rule that a path
|
|
26
|
+
parameter's name is not part of its identity. Findings carry a match grade:
|
|
27
|
+
`G1` the spellings already agreed, `G2` they agree once normalized, `G0`
|
|
28
|
+
only one view has it.
|
|
29
|
+
- Near-miss detection. An endpoint found in one view is checked against the
|
|
30
|
+
others for a same-path-different-verb or one-segment-apart match; findings
|
|
31
|
+
carrying one are demoted and flagged, and the count is printed beside the
|
|
32
|
+
totals.
|
|
33
|
+
- Held-back rules. A rule only runs when every view it reasons about was in
|
|
34
|
+
the scan, and two populated views sharing no endpoint at all suppress the
|
|
35
|
+
comparison rather than reporting it as hundreds of findings. Both are named
|
|
36
|
+
in the report.
|
|
37
|
+
- Reachability coverage for the gateway and infrastructure views, which answer
|
|
38
|
+
*does this reach that endpoint* rather than *does this contain it*.
|
|
39
|
+
- `-f json` and `-f sarif` output. A scan noir could not read in full reports
|
|
40
|
+
`executionSuccessful: false`, so a degraded run does not pass as a clean one.
|
|
41
|
+
- `--fail-on SEVERITY` for gating in CI.
|
|
42
|
+
- `--snapshot` and `alibi history`, which record which rules evaluated so that
|
|
43
|
+
a rule that stopped running is not read as a pile of resolved findings.
|
|
44
|
+
- Suppression through `.alibi.yml` or `--ignore REGEX`. Suppressed findings
|
|
45
|
+
are counted and the count is printed.
|
|
46
|
+
- `alibi doctor`, which reports technologies this noir build knows that the
|
|
47
|
+
view map does not.
|
|
48
|
+
- `--noir-arg` and a bare `--` for passing flags through to noir.
|
|
49
|
+
- `alibi --version`.
|
|
50
|
+
- A minimum noir version of 1.0.0, checked before a scan is spent.
|
|
51
|
+
|
|
52
|
+
[Unreleased]: https://github.com/owasp-noir/alibi/compare/v0.1.0...HEAD
|
|
53
|
+
[0.1.0]: https://github.com/owasp-noir/alibi/releases/tag/v0.1.0
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Setting up
|
|
4
|
+
|
|
5
|
+
```console
|
|
6
|
+
$ uv sync --group dev
|
|
7
|
+
$ uv run pytest -q
|
|
8
|
+
$ uv run ruff check .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
[noir](https://github.com/owasp-noir/noir) 1.0.0 or newer on `PATH` is
|
|
12
|
+
optional for development but not for judging a change. Six end-to-end tests
|
|
13
|
+
skip themselves when it is absent, and those are the only ones that exercise
|
|
14
|
+
the contract this tool is built on -- noir's JSON, its `list techs` catalog,
|
|
15
|
+
its tagger output. `pytest -rs` names what skipped; if the noir tests are in
|
|
16
|
+
that list, the suite has not tested the integration.
|
|
17
|
+
|
|
18
|
+
`uv run alibi doctor` reports technologies the installed noir knows that
|
|
19
|
+
`views.yml` does not place.
|
|
20
|
+
|
|
21
|
+
## What a change has to carry
|
|
22
|
+
|
|
23
|
+
- **A test that fails without it.** The commit history is a record of specific
|
|
24
|
+
wrong answers on real repositories; `tests/` is where each one is pinned so
|
|
25
|
+
it does not come back.
|
|
26
|
+
- **The reason, in the code.** Comments here explain why a rule exists, not
|
|
27
|
+
what the line does -- usually by naming the repository and the number that
|
|
28
|
+
made it necessary. A threshold with no such note is a threshold nobody can
|
|
29
|
+
safely change later.
|
|
30
|
+
|
|
31
|
+
## Rules and views are data
|
|
32
|
+
|
|
33
|
+
`src/alibi/rules.yml` and `src/alibi/views.yml` are read, not compiled. A new
|
|
34
|
+
rule or a newly-mapped technology is usually a change to those files and a
|
|
35
|
+
test, not to Python.
|
|
36
|
+
|
|
37
|
+
## Releasing
|
|
38
|
+
|
|
39
|
+
1. Update `version` in `pyproject.toml` and move the `Unreleased` section of
|
|
40
|
+
`CHANGELOG.md` under the new number.
|
|
41
|
+
2. Merge that to `main`.
|
|
42
|
+
3. Tag it: `git tag v0.2.0 && git push origin v0.2.0`.
|
|
43
|
+
|
|
44
|
+
`.github/workflows/release.yml` takes it from there -- it refuses a tag that
|
|
45
|
+
disagrees with `pyproject.toml`, runs the suite, checks that the wheel carries
|
|
46
|
+
`views.yml` and `rules.yml`, publishes to PyPI through Trusted Publishing, and
|
|
47
|
+
opens the GitHub release. There is no API token to hold.
|
noir_alibi-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OWASP Noir
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: noir-alibi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Cross-check the views of your attack surface and find the endpoints that cannot corroborate each other
|
|
5
|
+
Project-URL: Homepage, https://github.com/owasp-noir/alibi
|
|
6
|
+
Project-URL: Issues, https://github.com/owasp-noir/alibi/issues
|
|
7
|
+
Author-email: hahwul <hahwul@gmail.com>, ksg97031 <ksg97031@gmail.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: api,attack-surface,noir,security,shadow-api
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Topic :: Security
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# alibi
|
|
22
|
+
|
|
23
|
+
Cross-check the views of your attack surface and find the endpoints that cannot
|
|
24
|
+
corroborate each other.
|
|
25
|
+
|
|
26
|
+
An endpoint should be able to account for itself. It is in the code, so a
|
|
27
|
+
contract should describe it. It is in the contract, so something should
|
|
28
|
+
implement it. It takes real traffic, so it had better exist somewhere. When one
|
|
29
|
+
view knows about an endpoint and the others do not, that gap is the finding.
|
|
30
|
+
|
|
31
|
+
alibi runs [OWASP noir](https://github.com/owasp-noir/noir), reads its JSON, and
|
|
32
|
+
compares the views against each other.
|
|
33
|
+
|
|
34
|
+
## Why this is a separate tool
|
|
35
|
+
|
|
36
|
+
Noir already reads five independent views of the same surface:
|
|
37
|
+
|
|
38
|
+
| View | Read from |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| **code** | 200-plus analyzers across 33 languages |
|
|
41
|
+
| **doc** | OpenAPI, RAML, WSDL, GraphQL SDL, AsyncAPI, gRPC, Smithy, TypeSpec, OData, OpenRPC |
|
|
42
|
+
| **traffic** | HAR, mitmproxy, Burp, Caido, ZAP, Postman, Insomnia, Bruno, `.http` |
|
|
43
|
+
| **gateway** | nginx, Apache, Envoy, Kong, Traefik, APISIX, Caddy, Istio, Kubernetes Ingress and Gateway API |
|
|
44
|
+
| **infra** | Terraform, CloudFormation, CDK, Serverless, Vercel, Netlify, Wrangler, Azure Functions, Kamal |
|
|
45
|
+
|
|
46
|
+
What it does not do is compare them. That is the whole job here, and it needs no
|
|
47
|
+
change to noir — alibi runs it once per view and joins the results.
|
|
48
|
+
|
|
49
|
+
The per-view part matters. Noir deduplicates by `(method, url)` across every
|
|
50
|
+
analyzer, so a Flask route and an OpenAPI path spelled identically collapse into
|
|
51
|
+
one endpoint carrying one technology. That is right for a discovery tool — it is
|
|
52
|
+
one endpoint — but it erases the corroboration this tool is built to measure,
|
|
53
|
+
and it erases it in the worst possible direction: the better two views agree,
|
|
54
|
+
the more of them vanish. Casdoor scans as 372 code endpoints and 9 documented
|
|
55
|
+
ones; scan its `swagger/` directory alone and the specification has 235.
|
|
56
|
+
|
|
57
|
+
`--only-techs` restricts the detector pool, so one scan per view keeps each one
|
|
58
|
+
whole. Which technology speaks for which view is `views.yml`; which
|
|
59
|
+
technologies exist is whatever `noir list techs` reports.
|
|
60
|
+
|
|
61
|
+
alibi parses no API formats of its own. Its only input is noir's JSON.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
Requires [noir](https://github.com/owasp-noir/noir) **1.0.0 or newer** on
|
|
66
|
+
`PATH` -- that is the release where `noir list techs` became a subcommand, and
|
|
67
|
+
that catalog is what assigns every technology to a view. Development tracks the
|
|
68
|
+
current noir release. An older binary is refused by name rather than left to
|
|
69
|
+
fail on its first catalog read.
|
|
70
|
+
|
|
71
|
+
```console
|
|
72
|
+
$ uv tool install noir-alibi # or: pipx install noir-alibi
|
|
73
|
+
$ alibi scan ./my-service
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Use
|
|
77
|
+
|
|
78
|
+
```console
|
|
79
|
+
$ alibi scan # the working directory
|
|
80
|
+
$ alibi scan ./service ./contracts ./prod.har # or wherever the views live
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Every path is a source, scanned once per view. Point it at whatever you have —
|
|
84
|
+
a source tree, a spec directory, a single capture file — and the views you are
|
|
85
|
+
missing switch their rules off rather than flooding the report.
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
alibi · 1 source · 377 endpoints
|
|
89
|
+
|
|
90
|
+
code 372 doc 235
|
|
91
|
+
|
|
92
|
+
230 corroborated -- vouched for by more than one view
|
|
93
|
+
|
|
94
|
+
19 endpoints nearly matched another view -- these may be matching failures, not real gaps
|
|
95
|
+
|
|
96
|
+
SHADOW Shadow API -- Implemented, but no contract describes it
|
|
97
|
+
134 findings · 4 critical, 57 high, 62 medium, 11 low
|
|
98
|
+
|
|
99
|
+
critical POST /api/upload-groups router.go:87
|
|
100
|
+
upload paths carry more consequence than reads
|
|
101
|
+
critical POST /api/upload-permissions router.go:208
|
|
102
|
+
...
|
|
103
|
+
... and 122 more (SHADOW in full: -f json)
|
|
104
|
+
|
|
105
|
+
TWO SURFACES?
|
|
106
|
+
The doc view is 97% under /api, and 37 of these findings are outside it.
|
|
107
|
+
If that is a separate surface the contract never covered, narrow the scan:
|
|
108
|
+
alibi scan <paths> --ignore '^/(?!api/)'
|
|
109
|
+
If it is the same surface left undocumented, they are the findings that matter most.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Groups stop at twelve — the ordering is worst-first, so the tail is the least
|
|
113
|
+
informative part, and `-f json` has all of it.
|
|
114
|
+
|
|
115
|
+
### In CI
|
|
116
|
+
|
|
117
|
+
```yaml
|
|
118
|
+
- run: alibi scan . ./contracts -f sarif > alibi.sarif
|
|
119
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
120
|
+
with: { sarif_file: alibi.sarif }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Or gate directly: `alibi scan . ./contracts --fail-on high` exits non-zero when
|
|
124
|
+
a finding reaches that severity. A scan noir could not read in full reports
|
|
125
|
+
`executionSuccessful: false`, so a degraded run does not pass as a clean one.
|
|
126
|
+
|
|
127
|
+
## How endpoints are matched
|
|
128
|
+
|
|
129
|
+
Noir keeps each framework's own route syntax rather than inventing a common one,
|
|
130
|
+
so the same endpoint arrives spelled several ways:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
python_flask /api/users/<int:user_id>
|
|
134
|
+
aiohttp /users/{id}
|
|
135
|
+
java_spring /api/catalog/{id}
|
|
136
|
+
oas3 /v1/pets/{petId}
|
|
137
|
+
rails /posts/:id
|
|
138
|
+
nginx /admin/.*
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The rule that makes these comparable: **a path parameter's name is not part of
|
|
142
|
+
its identity.** `{petId}` and `<int:user_id>` describe the same slot; only its
|
|
143
|
+
position and whether it spans a `/` matter. Names are kept as evidence and
|
|
144
|
+
reported, but never reach the key.
|
|
145
|
+
|
|
146
|
+
Findings say how the match was made:
|
|
147
|
+
|
|
148
|
+
| Grade | Meaning |
|
|
149
|
+
| --- | --- |
|
|
150
|
+
| `G1` | the spellings already agreed |
|
|
151
|
+
| `G2` | they agree once parameter syntax is normalized |
|
|
152
|
+
| `G0` | only one view has it — nothing was matched |
|
|
153
|
+
|
|
154
|
+
## What keeps it honest
|
|
155
|
+
|
|
156
|
+
A tool like this dies by reporting hundreds of findings on its first run, or by
|
|
157
|
+
reporting progress nobody made. Six things push back:
|
|
158
|
+
|
|
159
|
+
**Rules do not fire without both views.** Scan a codebase with no contracts
|
|
160
|
+
anywhere and every endpoint technically qualifies as an undocumented shadow API.
|
|
161
|
+
Those findings say nothing except that you did not supply any documentation, so
|
|
162
|
+
a rule only runs when every view it reasons about was actually in the scan. The
|
|
163
|
+
report names the rules that sat out.
|
|
164
|
+
|
|
165
|
+
**Near misses are reported as doubt, not as findings.** "In code, not in the
|
|
166
|
+
docs" is indistinguishable from "in both, but alibi failed to line them up." So
|
|
167
|
+
an endpoint that lands in one view is checked against the others for a near
|
|
168
|
+
miss — same path with a different verb, or one segment apart where one side has
|
|
169
|
+
a parameter and the other a literal. Findings carrying a near miss are demoted
|
|
170
|
+
and flagged for review. That count sits next to the totals, because every
|
|
171
|
+
finding is only as trustworthy as it is small.
|
|
172
|
+
|
|
173
|
+
**Views that never met are one diagnostic, not hundreds of findings.** Argo CD
|
|
174
|
+
registers `/api` in Go and documents 198 paths beneath it, so its code and its
|
|
175
|
+
specification share not one endpoint. Read literally that is 58 shadow APIs and
|
|
176
|
+
198 phantom contracts, none of them real. Zero corroboration between two
|
|
177
|
+
populated views means the comparison did not work — a mount point standing in
|
|
178
|
+
for the routes beneath it, or a stack noir could not read — so the rules are
|
|
179
|
+
held back and the reason is printed instead. Paths that turn out to have many
|
|
180
|
+
endpoints from other views beneath them are labelled as probable mounts.
|
|
181
|
+
|
|
182
|
+
**A missing view and an empty one mean opposite things.** Noir reports what it
|
|
183
|
+
could not read, and alibi prints that above the findings. NetBox ships a 12.35MB
|
|
184
|
+
OpenAPI document with 308 paths; noir skips it for exceeding its file-size cap,
|
|
185
|
+
and without that report alibi states the project documents nothing — not merely
|
|
186
|
+
incomplete, but the wrong answer stated confidently.
|
|
187
|
+
|
|
188
|
+
**A rule that stopped running has not resolved anything.** Recording scans and
|
|
189
|
+
comparing them reintroduces the same mistake at a distance: forget the
|
|
190
|
+
contracts directory on one run and `SHADOW` evaluates nothing, which to a naive
|
|
191
|
+
difference looks exactly like every shadow API having been closed. On the
|
|
192
|
+
five-view fixture, dropping one argument turned seven standing findings into
|
|
193
|
+
"resolved". Snapshots record which rules evaluated, differences only consider
|
|
194
|
+
rules that ran in both scans, and the rest are named under `NOT COMPARED`.
|
|
195
|
+
|
|
196
|
+
**An absence is only evidence when the signal exists.** Noir's auth taggers
|
|
197
|
+
cover the frameworks they know. In a stack they do not cover, nothing carries an
|
|
198
|
+
auth tag, and treating that as "unauthenticated" would promote every finding and
|
|
199
|
+
drain the severity column of meaning. Adjustments that fire on a missing tag
|
|
200
|
+
require that tag to appear somewhere in the scan first.
|
|
201
|
+
|
|
202
|
+
## Rules
|
|
203
|
+
|
|
204
|
+
| Rule | Condition | Severity |
|
|
205
|
+
| --- | --- | --- |
|
|
206
|
+
| `ORPHAN` | taking real requests, absent from the code | high |
|
|
207
|
+
| `LIVE_UNDOC` | taking real requests, described by no contract | high |
|
|
208
|
+
| `SHADOW` | in code, not in any contract | medium |
|
|
209
|
+
| `DANGLING` | a gateway rule that reaches nothing implemented | medium |
|
|
210
|
+
| `DRIFT` | declared for deployment, missing from the code | medium |
|
|
211
|
+
| `PHANTOM` | in a contract, not in the code | low |
|
|
212
|
+
| `UNEXPOSED` | implemented, but no gateway rule reaches it | low |
|
|
213
|
+
| `COLD` | implemented, never seen taking a request | info |
|
|
214
|
+
|
|
215
|
+
Severity then shifts on what noir's taggers found: personal data, file uploads,
|
|
216
|
+
no sign of authentication, or a method that changes state.
|
|
217
|
+
|
|
218
|
+
Both the view map (`views.yml`) and the rules (`rules.yml`) are data, not code.
|
|
219
|
+
|
|
220
|
+
### Gateways are not endpoint lists
|
|
221
|
+
|
|
222
|
+
One `location /api/` stands for everything beneath it, so gateway and
|
|
223
|
+
infrastructure rules answer *does this reach that endpoint* rather than *does
|
|
224
|
+
this contain it*. Compared as sets, every prefix rule looks like a route nobody
|
|
225
|
+
implemented and every implemented route looks unreachable.
|
|
226
|
+
|
|
227
|
+
Coverage is deliberately generous. Noir reports the path a rule matches but not
|
|
228
|
+
whether it matches as a prefix or exactly (`location = /x`, an Ingress
|
|
229
|
+
`pathType: Exact`), so exactness cannot be recovered — and treating every rule
|
|
230
|
+
as a prefix suppresses findings rather than inventing them.
|
|
231
|
+
|
|
232
|
+
The report says how much of the code each routing view reaches, because whether
|
|
233
|
+
"34 endpoints no gateway reaches" is real depends on whether that config is the
|
|
234
|
+
one fronting the service. No threshold separates those honestly: Argo CD's e2e
|
|
235
|
+
test fixture reaches 39% of its code and NetBox's real config reaches 100%.
|
|
236
|
+
|
|
237
|
+
### Traffic has to have been watched
|
|
238
|
+
|
|
239
|
+
A HAR capture records requests that happened. A Postman collection records
|
|
240
|
+
requests somebody meant to make. `ORPHAN`, `LIVE_UNDOC` and `COLD` all reason
|
|
241
|
+
about what ran, so they require a view somebody actually watched and say so
|
|
242
|
+
when they sit out.
|
|
243
|
+
|
|
244
|
+
### Non-web surface stays out
|
|
245
|
+
|
|
246
|
+
Noir reports CLI arguments, Kafka topics and mobile deep links in the same
|
|
247
|
+
list. `cli://gitops-engine/agent` flattened into HTTP becomes `/agent` — it
|
|
248
|
+
collides with any web route of that name and gets asked whether a gateway
|
|
249
|
+
routes to it. The protocol belongs to the endpoint's identity; `http` and
|
|
250
|
+
`https` are one space and everything else keeps its own.
|
|
251
|
+
|
|
252
|
+
## Suppression
|
|
253
|
+
|
|
254
|
+
Some gaps are the intended state. Put an `.alibi.yml` beside the source:
|
|
255
|
+
|
|
256
|
+
```yaml
|
|
257
|
+
ignore:
|
|
258
|
+
- path: "^/internal/"
|
|
259
|
+
why: internal-only admin surface
|
|
260
|
+
- rule: UNEXPOSED
|
|
261
|
+
path: "^/debug/"
|
|
262
|
+
why: not fronted by the gateway in this repo
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Or pass `--ignore REGEX` for a one-off. Suppressed findings are counted and the
|
|
266
|
+
count is printed — a tool that quietly drops findings is worse than one that
|
|
267
|
+
prints too many, because there is no longer any way to tell what it withheld.
|
|
268
|
+
|
|
269
|
+
## Status
|
|
270
|
+
|
|
271
|
+
Early, but all five views are compared.
|
|
272
|
+
|
|
273
|
+
Measured against five repositories:
|
|
274
|
+
|
|
275
|
+
| Repository | code | doc | corroborated | findings | code↔doc |
|
|
276
|
+
| --- | ---: | ---: | ---: | ---: | --- |
|
|
277
|
+
| casdoor | 372 | 235 | **230 (98%)** | 139 | compared |
|
|
278
|
+
| netbox | 1146 | 1193 | **796 (67%)** | 746 | compared |
|
|
279
|
+
| argo-cd | 59 | 198 | 1 | 31 | held back |
|
|
280
|
+
| authentik | 231 | 1193 | 1 | 192 | held back |
|
|
281
|
+
| flipt | 2 | 42 | 0 | 0 | held back |
|
|
282
|
+
|
|
283
|
+
Casdoor is the cleanest case: **230 of its 235 documented endpoints matched the
|
|
284
|
+
code, with no path normalization failures at all.** All 19 near misses were the
|
|
285
|
+
same path under a different verb — noir registering every method on a Go
|
|
286
|
+
catch-all handler, not a matching problem.
|
|
287
|
+
|
|
288
|
+
NetBox is the instructive one. It holds two surfaces in one repository: a
|
|
289
|
+
server-rendered web UI and a DRF-router REST API that only the second is
|
|
290
|
+
documented. Scanned whole it reports 746 findings, most of them the true but
|
|
291
|
+
useless observation that a web UI is not in an API specification. Scoped to the
|
|
292
|
+
surface the contract describes, it collapses to what was actually worth saying:
|
|
293
|
+
|
|
294
|
+
```console
|
|
295
|
+
$ alibi scan ./netbox --ignore '^/(?!api/)'
|
|
296
|
+
```
|
|
297
|
+
→ 3 shadow APIs: `/api/plugins`, `/api/schema/redoc`, `/api/schema/swagger-ui`,
|
|
298
|
+
all three genuinely served and genuinely absent from the schema. The 397
|
|
299
|
+
phantoms that remain are the bulk operations NetBox's own router subclass adds
|
|
300
|
+
to every list endpoint, which no urlconf walk can see.
|
|
301
|
+
|
|
302
|
+
The other three are held back, each for a reason worth knowing:
|
|
303
|
+
|
|
304
|
+
- **Argo CD** registers `/api` in Go and documents 198 paths beneath it — the
|
|
305
|
+
same surface at two granularities.
|
|
306
|
+
- **authentik** assembles its URLconf at runtime by importing every installed
|
|
307
|
+
app's `urls` module, which no static reader can follow.
|
|
308
|
+
- **flipt** mounts a gRPC gateway; its Go source holds one route.
|
|
309
|
+
|
|
310
|
+
Which is this tool's ceiling, stated plainly: it compares what noir can read,
|
|
311
|
+
and a view read at the wrong granularity is worse than one not read at all.
|
|
312
|
+
Most of the machinery above exists to tell those apart rather than to report
|
|
313
|
+
them as defects.
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
MIT
|