codexlens 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.
- codexlens-0.1.0/.gitattributes +2 -0
- codexlens-0.1.0/.github/workflows/ci.yml +54 -0
- codexlens-0.1.0/.github/workflows/release.yml +69 -0
- codexlens-0.1.0/.gitignore +14 -0
- codexlens-0.1.0/BUILD_WEEK_DEMO_SCRIPT.md +101 -0
- codexlens-0.1.0/CHANGELOG.md +26 -0
- codexlens-0.1.0/LICENSE +21 -0
- codexlens-0.1.0/PKG-INFO +251 -0
- codexlens-0.1.0/README.md +202 -0
- codexlens-0.1.0/RELEASE_NOTES.md +29 -0
- codexlens-0.1.0/SECURITY.md +36 -0
- codexlens-0.1.0/examples/expenseflow/.gitignore +5 -0
- codexlens-0.1.0/examples/expenseflow/README.md +154 -0
- codexlens-0.1.0/examples/expenseflow/pyproject.toml +31 -0
- codexlens-0.1.0/examples/expenseflow/scripts/prepare_demo.py +27 -0
- codexlens-0.1.0/examples/expenseflow/tests/test_exploit_proof.py +25 -0
- codexlens-0.1.0/examples/expenseflow/tests/test_hardened_reference.py +18 -0
- codexlens-0.1.0/examples/expenseflow/tests/test_live_patch.py +43 -0
- codexlens-0.1.0/examples/expenseflow/uv.lock +396 -0
- codexlens-0.1.0/examples/expenseflow/vulnerable/__init__.py +1 -0
- codexlens-0.1.0/examples/expenseflow/vulnerable/app/__init__.py +1 -0
- codexlens-0.1.0/examples/expenseflow/vulnerable/app/hardened_reference.py +27 -0
- codexlens-0.1.0/examples/expenseflow/vulnerable/app/main.py +195 -0
- codexlens-0.1.0/pyproject.toml +63 -0
- codexlens-0.1.0/src/codexlens/__init__.py +3 -0
- codexlens-0.1.0/src/codexlens/__main__.py +6 -0
- codexlens-0.1.0/src/codexlens/ai_analysis/__init__.py +5 -0
- codexlens-0.1.0/src/codexlens/ai_analysis/context.py +333 -0
- codexlens-0.1.0/src/codexlens/ai_analysis/prompts.py +137 -0
- codexlens-0.1.0/src/codexlens/ai_analysis/service.py +496 -0
- codexlens-0.1.0/src/codexlens/application.py +17 -0
- codexlens-0.1.0/src/codexlens/auto_fix/__init__.py +6 -0
- codexlens-0.1.0/src/codexlens/auto_fix/apply.py +174 -0
- codexlens-0.1.0/src/codexlens/auto_fix/models.py +87 -0
- codexlens-0.1.0/src/codexlens/auto_fix/prompts.py +94 -0
- codexlens-0.1.0/src/codexlens/auto_fix/service.py +160 -0
- codexlens-0.1.0/src/codexlens/auto_fix/validation.py +459 -0
- codexlens-0.1.0/src/codexlens/auto_fix/workflow.py +248 -0
- codexlens-0.1.0/src/codexlens/cli.py +151 -0
- codexlens-0.1.0/src/codexlens/config.py +42 -0
- codexlens-0.1.0/src/codexlens/demo.py +332 -0
- codexlens-0.1.0/src/codexlens/models.py +190 -0
- codexlens-0.1.0/src/codexlens/reporting.py +382 -0
- codexlens-0.1.0/src/codexlens/static_analysis/__init__.py +5 -0
- codexlens-0.1.0/src/codexlens/static_analysis/ast_rules.py +217 -0
- codexlens-0.1.0/src/codexlens/static_analysis/discovery.py +148 -0
- codexlens-0.1.0/src/codexlens/static_analysis/engine.py +108 -0
- codexlens-0.1.0/src/codexlens/static_analysis/secrets.py +253 -0
- codexlens-0.1.0/tests/test_ai_analysis.py +197 -0
- codexlens-0.1.0/tests/test_application.py +98 -0
- codexlens-0.1.0/tests/test_auto_fix.py +515 -0
- codexlens-0.1.0/tests/test_cli.py +311 -0
- codexlens-0.1.0/tests/test_config.py +39 -0
- codexlens-0.1.0/tests/test_demo.py +55 -0
- codexlens-0.1.0/tests/test_json_output.py +144 -0
- codexlens-0.1.0/tests/test_static_analysis.py +166 -0
- codexlens-0.1.0/uv.lock +535 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
quality:
|
|
12
|
+
name: Python 3.11 quality checks
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Check out source
|
|
17
|
+
uses: actions/checkout@v6
|
|
18
|
+
|
|
19
|
+
- name: Set up Python
|
|
20
|
+
uses: actions/setup-python@v6
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.11"
|
|
23
|
+
|
|
24
|
+
- name: Set up uv
|
|
25
|
+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
|
|
26
|
+
with:
|
|
27
|
+
enable-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Install locked dependencies
|
|
30
|
+
run: uv sync --all-groups --frozen
|
|
31
|
+
|
|
32
|
+
- name: Lint
|
|
33
|
+
run: uv run ruff check .
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: uv run pytest
|
|
37
|
+
|
|
38
|
+
- name: Validate owned ExpenseFlow fixture
|
|
39
|
+
working-directory: examples/expenseflow
|
|
40
|
+
run: |
|
|
41
|
+
uv sync --all-groups --frozen
|
|
42
|
+
uv run pytest
|
|
43
|
+
uv run ruff check .
|
|
44
|
+
|
|
45
|
+
- name: Generate machine-readable static report
|
|
46
|
+
run: uv run codexlens scan src --format json > codexlens-report.json
|
|
47
|
+
|
|
48
|
+
- name: Upload static report
|
|
49
|
+
uses: actions/upload-artifact@v7
|
|
50
|
+
with:
|
|
51
|
+
name: codexlens-static-report
|
|
52
|
+
path: codexlens-report.json
|
|
53
|
+
if-no-files-found: error
|
|
54
|
+
retention-days: 7
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish-github-release:
|
|
13
|
+
name: Build and publish GitHub Release
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Check out release tag
|
|
18
|
+
uses: actions/checkout@v6
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v6
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.11"
|
|
26
|
+
|
|
27
|
+
- name: Set up uv
|
|
28
|
+
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
|
|
29
|
+
with:
|
|
30
|
+
enable-cache: true
|
|
31
|
+
|
|
32
|
+
- name: Install locked dependencies
|
|
33
|
+
run: uv sync --all-groups --frozen
|
|
34
|
+
|
|
35
|
+
- name: Verify quality
|
|
36
|
+
run: |
|
|
37
|
+
uv run ruff check .
|
|
38
|
+
uv run pytest
|
|
39
|
+
|
|
40
|
+
- name: Verify tag matches package version
|
|
41
|
+
shell: bash
|
|
42
|
+
run: |
|
|
43
|
+
tag_version="${GITHUB_REF_NAME#v}"
|
|
44
|
+
package_version="$(uv run python -c "from importlib.metadata import version; print(version('codexlens'))")"
|
|
45
|
+
test "$tag_version" = "$package_version"
|
|
46
|
+
|
|
47
|
+
- name: Build distributions
|
|
48
|
+
run: uv build --out-dir dist
|
|
49
|
+
|
|
50
|
+
- name: Upload release artifacts
|
|
51
|
+
uses: actions/upload-artifact@v7
|
|
52
|
+
with:
|
|
53
|
+
name: codexlens-${{ github.ref_name }}-distributions
|
|
54
|
+
path: dist/
|
|
55
|
+
if-no-files-found: error
|
|
56
|
+
|
|
57
|
+
- name: Create or update GitHub Release
|
|
58
|
+
env:
|
|
59
|
+
GH_TOKEN: ${{ github.token }}
|
|
60
|
+
shell: bash
|
|
61
|
+
run: |
|
|
62
|
+
if gh release view "$GITHUB_REF_NAME" > /dev/null 2>&1; then
|
|
63
|
+
gh release upload "$GITHUB_REF_NAME" dist/* --clobber
|
|
64
|
+
else
|
|
65
|
+
gh release create "$GITHUB_REF_NAME" dist/* \
|
|
66
|
+
--verify-tag \
|
|
67
|
+
--title "CodexLens $GITHUB_REF_NAME" \
|
|
68
|
+
--notes-file RELEASE_NOTES.md
|
|
69
|
+
fi
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# CodexLens Build Week Demo Script
|
|
2
|
+
|
|
3
|
+
Use this as a recording checklist, not as a claim that the offline replay is a
|
|
4
|
+
live model run. Replace every bracketed placeholder with real submission
|
|
5
|
+
details before publishing.
|
|
6
|
+
|
|
7
|
+
## Preflight
|
|
8
|
+
|
|
9
|
+
- [ ] Repository is public with the MIT license, or shared with the event's
|
|
10
|
+
required review addresses.
|
|
11
|
+
- [ ] `uv sync --all-groups`, `uv run pytest`, and `uv run ruff check .` pass.
|
|
12
|
+
- [ ] The live model account has access to the GPT-5.6 model selected for the
|
|
13
|
+
Build Week recording.
|
|
14
|
+
- [ ] `OPENAI_API_KEY` is set locally and never shown in the video.
|
|
15
|
+
- [ ] The `examples/expenseflow/work/` copy is freshly prepared.
|
|
16
|
+
- [ ] The final Codex `/feedback` session ID for the core build is available.
|
|
17
|
+
|
|
18
|
+
## Under-three-minute recording outline
|
|
19
|
+
|
|
20
|
+
### 0:00–0:20 — Problem and product
|
|
21
|
+
|
|
22
|
+
Say: “Traditional static checks can find obvious dangerous calls, but they do
|
|
23
|
+
not reliably understand that an expense belongs to a tenant. CodexLens combines
|
|
24
|
+
local checks, model-assisted business-logic review, and a confirmation-gated
|
|
25
|
+
fix.”
|
|
26
|
+
|
|
27
|
+
Show the README architecture diagram or run:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv run codexlens demo
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If using this command, say clearly: “This is an offline recorded replay for
|
|
34
|
+
judges; it makes no API request.” Do not present it as the live GPT-5.6 result.
|
|
35
|
+
|
|
36
|
+
### 0:20–0:45 — Establish the real vulnerable behavior
|
|
37
|
+
|
|
38
|
+
From `examples/expenseflow/`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
uv run pytest tests/test_exploit_proof.py tests/test_hardened_reference.py
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Explain that the first test proves a manager in tenant Acme can approve a
|
|
45
|
+
Globex expense, while the hardened reference defines the correct invariant.
|
|
46
|
+
|
|
47
|
+
### 0:45–1:55 — Live selected-model scan and review
|
|
48
|
+
|
|
49
|
+
From the repository root, use the actual GPT-5.6 model ID available to the
|
|
50
|
+
recording account:
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
uv run python examples/expenseflow/scripts/prepare_demo.py
|
|
54
|
+
$env:CODEXLENS_MODEL = "[your GPT-5.6 model ID]"
|
|
55
|
+
uv run codexlens scan examples/expenseflow/work/app/main.py --fix
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Narrate the evidence, not just the label: the route checks that the caller is a
|
|
59
|
+
manager, then looks up an attacker-controlled expense ID without limiting it to
|
|
60
|
+
the actor's tenant. Point out the AI finding is labeled for human review.
|
|
61
|
+
|
|
62
|
+
Show the generated Rich diff. State that CodexLens produced the diff locally
|
|
63
|
+
from a validated one-source-unit replacement. Review it, then explicitly press
|
|
64
|
+
`y`; do not automate this input.
|
|
65
|
+
|
|
66
|
+
### 1:55–2:20 — Verify the repaired behavior
|
|
67
|
+
|
|
68
|
+
From `examples/expenseflow/`:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
uv run pytest tests/test_live_patch.py
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Explain that the request is now denied and the original expense stays
|
|
75
|
+
unapproved. Show that `vulnerable/` was not changed; only the ignored disposable
|
|
76
|
+
`work/` copy was eligible for the live patch.
|
|
77
|
+
|
|
78
|
+
### 2:20–2:50 — Engineering and Codex use
|
|
79
|
+
|
|
80
|
+
Show the JSON CI output or the workflow briefly:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
uv run codexlens scan src --format json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Say only what is true for the final project. A safe, accurate framing is:
|
|
87
|
+
“I used Codex as an implementation partner to design the constrained patch
|
|
88
|
+
workflow, build the owned demo fixture, and add tests for confirmation, stale
|
|
89
|
+
source, and JSON reporting. GPT-5.6 performs the live business-logic review and
|
|
90
|
+
patch proposal in this recording.”
|
|
91
|
+
|
|
92
|
+
## Submission copy checklist
|
|
93
|
+
|
|
94
|
+
- [ ] Choose the Developer Tools category.
|
|
95
|
+
- [ ] Include the project description, repository URL, setup commands, and
|
|
96
|
+
supported platform (Python 3.11+ on Windows, macOS, and Linux).
|
|
97
|
+
- [ ] Link the public narrated video and keep it below the event time limit.
|
|
98
|
+
- [ ] Explain that the no-key `codexlens demo` command is a recorded replay and
|
|
99
|
+
the ExpenseFlow fixture is intentionally vulnerable and non-deployable.
|
|
100
|
+
- [ ] Highlight the live GPT-5.6 scan separately from the no-key replay.
|
|
101
|
+
- [ ] Add the Codex `/feedback` session ID: `[paste session ID here]`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to CodexLens are documented in this file.
|
|
4
|
+
|
|
5
|
+
The project follows [Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-07-20
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Three-pass Python security-auditing pipeline: local static analysis,
|
|
12
|
+
model-assisted business-logic review, and confirmation-gated auto-fix.
|
|
13
|
+
- Model-neutral OpenAI Responses API integration selected with `--model` or
|
|
14
|
+
`CODEXLENS_MODEL`.
|
|
15
|
+
- Locally validated, single-source-unit patch proposals with an explicit
|
|
16
|
+
`y`/`n` decision and atomic application safeguards.
|
|
17
|
+
- Source-free JSON reporting for CI and a GitHub Actions quality workflow.
|
|
18
|
+
- An owned ExpenseFlow IDOR demonstration, exploit proof, hardened reference,
|
|
19
|
+
regression test, and credential-free offline replay.
|
|
20
|
+
- `codexlens --version` for release verification and support workflows.
|
|
21
|
+
|
|
22
|
+
### Security
|
|
23
|
+
|
|
24
|
+
- Heuristic redaction before optional model-assisted analysis.
|
|
25
|
+
- Strict local validation of model output and patch bindings before a file can
|
|
26
|
+
be changed.
|
codexlens-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shreyash Chaurasia
|
|
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.
|
codexlens-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codexlens
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI-powered security auditing for Python projects.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ShreyashChaurasia/CodexLens
|
|
6
|
+
Project-URL: Repository, https://github.com/ShreyashChaurasia/CodexLens
|
|
7
|
+
Project-URL: Issues, https://github.com/ShreyashChaurasia/CodexLens/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/ShreyashChaurasia/CodexLens/blob/main/CHANGELOG.md
|
|
9
|
+
Author: Shreyash Chaurasia
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Shreyash Chaurasia
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Keywords: application-security,cli,openai,python,static-analysis
|
|
33
|
+
Classifier: Development Status :: 4 - Beta
|
|
34
|
+
Classifier: Environment :: Console
|
|
35
|
+
Classifier: Intended Audience :: Developers
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Operating System :: OS Independent
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Security
|
|
43
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
44
|
+
Requires-Python: >=3.11
|
|
45
|
+
Requires-Dist: openai<3.0.0,>=1.0.0
|
|
46
|
+
Requires-Dist: rich<15.0.0,>=13.7.0
|
|
47
|
+
Requires-Dist: typer<1.0.0,>=0.15.0
|
|
48
|
+
Description-Content-Type: text/markdown
|
|
49
|
+
|
|
50
|
+
# CodexLens
|
|
51
|
+
|
|
52
|
+
CodexLens is a Python CLI security auditor for projects that need more than
|
|
53
|
+
pattern matching. It combines deterministic local checks with optional
|
|
54
|
+
AI-assisted business-logic review, then presents constrained code fixes in a
|
|
55
|
+
Rich terminal diff. A source file changes only after explicit confirmation.
|
|
56
|
+
|
|
57
|
+
This repository provides a reproducible OpenAI Build Week demonstration of the
|
|
58
|
+
complete workflow: static analysis, an AI review candidate, a confirmation-gated
|
|
59
|
+
patch, and a security regression test.
|
|
60
|
+
|
|
61
|
+
## Evaluation paths
|
|
62
|
+
|
|
63
|
+
| Path | Credentials | Command | Outcome |
|
|
64
|
+
| --- | --- | --- | --- |
|
|
65
|
+
| Local static audit | None | `uv run codexlens scan src` | Pass 1 detection with no network request. |
|
|
66
|
+
| Offline workflow replay | None | `uv run codexlens demo` | A deterministic Rich-terminal replay; no OpenAI request and no repository modification. |
|
|
67
|
+
| Live end-to-end evaluation | OpenAI API key and model ID | [ExpenseFlow](examples/expenseflow/README.md) | A selected OpenAI model reviews and proposes a fix for the ExpenseFlow IDOR scenario. |
|
|
68
|
+
|
|
69
|
+
The offline replay is prominently labelled **offline recorded replay**. It is a
|
|
70
|
+
deterministic product walkthrough, not a substitute for a live model result.
|
|
71
|
+
|
|
72
|
+
## Capabilities
|
|
73
|
+
|
|
74
|
+
| Pass | Execution | Purpose | Output |
|
|
75
|
+
| --- | --- | --- | --- |
|
|
76
|
+
| 1. Static analysis | Local | Scans Python files with regex, entropy, and AST checks. | Confirmed findings, candidates, and diagnostics. |
|
|
77
|
+
| 2. AI deep scan | Optional OpenAI Responses API request | Reviews bounded, redacted source units for business-logic weaknesses. | Structured findings that require human review. |
|
|
78
|
+
| 3. Interactive auto-fix | Optional after completed Pass 2 | Proposes a narrowly scoped source-unit replacement. | A locally generated diff and an explicit `y`/`n` decision. |
|
|
79
|
+
|
|
80
|
+
Pass 1 detects likely hardcoded credentials and high-entropy secret candidates,
|
|
81
|
+
dynamic shell use, `shell=True`, `eval`/`exec`, unsafe pickle/YAML
|
|
82
|
+
deserialization, dynamically constructed database queries, and disabled TLS
|
|
83
|
+
verification. Pass 2 assesses broken object-level authorization (including
|
|
84
|
+
IDOR), privilege escalation, mass assignment, and race conditions.
|
|
85
|
+
|
|
86
|
+
AI findings are review candidates rather than confirmed vulnerabilities. The
|
|
87
|
+
tool is a security-review aid, not a security guarantee.
|
|
88
|
+
|
|
89
|
+
## Installation and local verification
|
|
90
|
+
|
|
91
|
+
### Requirements
|
|
92
|
+
|
|
93
|
+
- Python 3.11 or newer
|
|
94
|
+
- [uv](https://docs.astral.sh/uv/)
|
|
95
|
+
- An OpenAI API key only for Pass 2 and Pass 3
|
|
96
|
+
|
|
97
|
+
At the repository root:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
uv sync --all-groups
|
|
101
|
+
uv run codexlens --help
|
|
102
|
+
uv run codexlens scan src
|
|
103
|
+
uv run codexlens demo
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`scan src` runs Pass 1 only when no model is configured and makes no external
|
|
107
|
+
request. `demo` stages a self-contained ExpenseFlow example in a temporary directory,
|
|
108
|
+
replays schema-valid Pass 2 and Pass 3 responses through CodexLens' normal
|
|
109
|
+
local validation path, presents the confirmation prompt, and discards the
|
|
110
|
+
temporary source after completion.
|
|
111
|
+
|
|
112
|
+
## Live AI scanning
|
|
113
|
+
|
|
114
|
+
Live AI scanning requires an OpenAI API key and an accessible, text-capable
|
|
115
|
+
model that supports the structured response format used by CodexLens. The
|
|
116
|
+
model ID is supplied per live scan or through `CODEXLENS_MODEL`; CodexLens has
|
|
117
|
+
no hard-coded model-family default or client-side model allowlist.
|
|
118
|
+
|
|
119
|
+
PowerShell:
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
$env:OPENAI_API_KEY = "<api-key>"
|
|
123
|
+
$env:CODEXLENS_MODEL = "<model-id>"
|
|
124
|
+
uv run codexlens scan ./my_project
|
|
125
|
+
uv run codexlens scan ./my_project --model "another-model-id"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Bash or zsh:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
export OPENAI_API_KEY="<api-key>"
|
|
132
|
+
export CODEXLENS_MODEL="<model-id>"
|
|
133
|
+
uv run codexlens scan ./my_project
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The `--model` / `-m` value overrides `CODEXLENS_MODEL`. Without either value,
|
|
137
|
+
CodexLens intentionally completes only local Pass 1. With a model configured,
|
|
138
|
+
Pass 2 uses the OpenAI Responses API and Pass 3 makes a separate request only
|
|
139
|
+
when `--fix` is present. Model capabilities can be confirmed through OpenAI's
|
|
140
|
+
[model catalog](https://developers.openai.com/api/docs/models) and
|
|
141
|
+
[Structured Outputs guide](https://developers.openai.com/api/docs/guides/structured-outputs).
|
|
142
|
+
|
|
143
|
+
> **Data-handling notice:** A live scan sends bounded source context to OpenAI,
|
|
144
|
+
> and API usage is billed to the associated account. Known credentials,
|
|
145
|
+
> sensitive assignments, and high-entropy literals are redacted heuristically
|
|
146
|
+
> before submission, and API requests set `store=False`; these controls do not
|
|
147
|
+
> guarantee removal of every sensitive detail. Live scanning is appropriate
|
|
148
|
+
> only for code authorized for sharing with the selected service.
|
|
149
|
+
|
|
150
|
+
## Interactive patch review
|
|
151
|
+
|
|
152
|
+
A live Pass 3 run is requested with `--fix`:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
uv run codexlens scan ./my_project --model "model-id" --fix
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
| Safeguard | Behavior |
|
|
159
|
+
| --- | --- |
|
|
160
|
+
| Eligibility | Only findings from a completed Pass 2 scan and bound to a reviewed Python source unit can reach Pass 3. |
|
|
161
|
+
| Preview | CodexLens generates the unified diff locally after validating the replacement's target, scope, syntax, sensitive-content policy, bindings, and size. |
|
|
162
|
+
| Confirmation | `y` is the only input that applies a proposal. `n`, Enter, missing input, or an interrupted prompt declines it. |
|
|
163
|
+
| Application | A fresh file hash is checked before an atomic same-directory replacement. A run applies at most one validated patch. |
|
|
164
|
+
|
|
165
|
+
Declining a proposal permits review of another eligible proposal. After an
|
|
166
|
+
accepted patch, a new scan and the project's test suite provide the next
|
|
167
|
+
verification step. CodexLens does not execute model-provided commands or trust
|
|
168
|
+
model-provided file paths and diffs.
|
|
169
|
+
|
|
170
|
+
## ExpenseFlow showcase
|
|
171
|
+
|
|
172
|
+
[`examples/expenseflow/`](examples/expenseflow/README.md) is a self-contained,
|
|
173
|
+
intentionally vulnerable multi-tenant FastAPI service with synthetic data. The
|
|
174
|
+
primary scenario is a manager in one tenant approving an expense belonging to
|
|
175
|
+
another tenant: a broken-object-authorization / IDOR flaw that a role check
|
|
176
|
+
alone does not prevent.
|
|
177
|
+
|
|
178
|
+
The baseline evidence is reproducible:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
cd examples/expenseflow
|
|
182
|
+
uv sync --all-groups
|
|
183
|
+
uv run pytest tests/test_exploit_proof.py tests/test_hardened_reference.py
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The exploit-proof test passes by demonstrating the vulnerable cross-tenant
|
|
187
|
+
approval. The hardened-reference test documents the intended security property.
|
|
188
|
+
The example README contains the isolated live-patch workflow and post-patch
|
|
189
|
+
regression test. The fixture must not be deployed or reused outside this
|
|
190
|
+
controlled demonstration.
|
|
191
|
+
|
|
192
|
+
The [Build Week recording script](BUILD_WEEK_DEMO_SCRIPT.md) documents the
|
|
193
|
+
exploit → live scan → reviewed diff → regression-test sequence and separates
|
|
194
|
+
the no-key replay from the live selected-model demonstration.
|
|
195
|
+
|
|
196
|
+
## CI, reports, and exit codes
|
|
197
|
+
|
|
198
|
+
The Rich terminal UI is the default. `--format json` produces a stable,
|
|
199
|
+
machine-readable report for CI and other tooling:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
uv run codexlens scan src --format json > codexlens-report.json
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
The report schema is `codexlens.scan.v1`. It contains relative locations,
|
|
206
|
+
finding metadata, diagnostics, pass status, and the exit code. It intentionally
|
|
207
|
+
omits raw source, raw Responses API output, source-unit bindings, and patch
|
|
208
|
+
diffs. Finding descriptions can still contain code-derived information, so the
|
|
209
|
+
report should be handled as potentially sensitive.
|
|
210
|
+
|
|
211
|
+
| Exit code | Meaning |
|
|
212
|
+
| --- | --- |
|
|
213
|
+
| `0` | The requested scan completed with no confirmed static finding. |
|
|
214
|
+
| `1` | The scan completed with one or more confirmed static findings. |
|
|
215
|
+
| `3` | A requested scan or fix did not complete safely; the output contains a diagnostic. |
|
|
216
|
+
|
|
217
|
+
AI review candidates do not independently fail CI. `--format json` and `--fix`
|
|
218
|
+
cannot be combined because patch review requires the interactive Rich diff and
|
|
219
|
+
explicit confirmation.
|
|
220
|
+
|
|
221
|
+
The included [GitHub Actions workflow](.github/workflows/ci.yml) installs
|
|
222
|
+
locked dependencies on Python 3.11, runs Ruff and pytest for both projects, and
|
|
223
|
+
uploads the static JSON report as an artifact.
|
|
224
|
+
|
|
225
|
+
## Scope and security posture
|
|
226
|
+
|
|
227
|
+
- Pass 1 is local. Pass 2 and Pass 3 are opt-in and request `store=False`.
|
|
228
|
+
- Static detection and redaction are narrow heuristics, not complete
|
|
229
|
+
vulnerability coverage or data-loss prevention.
|
|
230
|
+
- CodexLens audits Python source files only. Incomplete static or AI coverage
|
|
231
|
+
produces diagnostics and exit code `3` instead of a silent success.
|
|
232
|
+
- Scanned code and model output are treated as untrusted data. Human review,
|
|
233
|
+
tests, and normal deployment controls remain required.
|
|
234
|
+
- The CLI targets Windows, macOS, and Linux shells; both PowerShell and POSIX
|
|
235
|
+
environment-variable syntax are documented above.
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
uv sync --all-groups
|
|
241
|
+
uv run ruff check .
|
|
242
|
+
uv run pytest
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Project information
|
|
246
|
+
|
|
247
|
+
- [Release history](https://github.com/ShreyashChaurasia/CodexLens/releases)
|
|
248
|
+
- [Changelog](CHANGELOG.md)
|
|
249
|
+
- [Security policy](SECURITY.md)
|
|
250
|
+
|
|
251
|
+
CodexLens is released under the [MIT License](LICENSE).
|