odooscan 0.2.0__py3-none-win_amd64.whl
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.
|
Binary file
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: odooscan
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Classifier: Development Status :: 3 - Alpha
|
|
5
|
+
Classifier: Environment :: Console
|
|
6
|
+
Classifier: Framework :: Odoo
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: Programming Language :: Python
|
|
9
|
+
Classifier: Programming Language :: Rust
|
|
10
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Summary: A quality and security scanner for Odoo modules that checks them against an index of every module they build on
|
|
13
|
+
Keywords: odoo,linter,static-analysis,security,pre-commit
|
|
14
|
+
License-Expression: MIT
|
|
15
|
+
Requires-Python: >=3.7
|
|
16
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
17
|
+
Project-URL: Changelog, https://github.com/avanserv/odooscan/blob/main/CHANGELOG.md
|
|
18
|
+
Project-URL: Repository, https://github.com/avanserv/odooscan
|
|
19
|
+
|
|
20
|
+
# odooscan
|
|
21
|
+
|
|
22
|
+
[](https://github.com/avanserv/odooscan/actions/workflows/ci.yml?query=branch%3Amain)
|
|
23
|
+
[](LICENSE)
|
|
24
|
+
[](.pre-commit-config.yaml)
|
|
25
|
+
[](https://github.com/ludo-technologies/polyscan)
|
|
26
|
+
[](https://www.conventionalcommits.org)
|
|
27
|
+
|
|
28
|
+
A quality and security scanner for Odoo modules, written in Rust. It parses Python with ruff's
|
|
29
|
+
parser, and XML and CSV natively. It then builds one index of every model, field, method, XML id,
|
|
30
|
+
view and access rule across the modules it is given, so rules can check what a single-file linter
|
|
31
|
+
cannot. For example, it can tell you that a view names a field its model lacks, or that an XML id
|
|
32
|
+
belongs to a module missing from `depends`.
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
uv tool install odooscan # or: pip install odooscan
|
|
36
|
+
oscn check path/to/custom-addons --addons-path ~/repos/odoo/odoo,~/repos/odoo/enterprise
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The wheels hold a prebuilt binary for Linux (glibc and musl), macOS and Windows; `cargo build
|
|
40
|
+
--release` builds `target/release/oscn` anywhere else.
|
|
41
|
+
|
|
42
|
+
The command is `oscn`. `check` reports on the modules found under the given paths. `--addons-path` holds what those
|
|
43
|
+
modules build on. It is indexed but never reported on, and an Odoo source checkout stands for its
|
|
44
|
+
`addons` and `odoo/addons` directories. The variable `ODOOSCAN_ADDONS_PATH` sets the same thing.
|
|
45
|
+
Without `base` on the addons path, the rules marked `needs_index` in `src/rules.rs` are off and a
|
|
46
|
+
notice says so.
|
|
47
|
+
|
|
48
|
+
Other options:
|
|
49
|
+
|
|
50
|
+
- `--format github` and `--format gitlab` are for CI (see below); `json` and `sarif` for other
|
|
51
|
+
tools.
|
|
52
|
+
- `--select OD3` and `--ignore OD111` filter by code prefix.
|
|
53
|
+
- `--exclude migrations/,tests/` hides findings in files matching gitignore-style patterns.
|
|
54
|
+
- `--statistics` prints counts per rule.
|
|
55
|
+
|
|
56
|
+
The exit status is 1 when anything is reported, and 2 when the settings are invalid.
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
`oscn check` reads the nearest `odooscan.toml`, or `pyproject.toml` with a `[tool.odooscan]`
|
|
61
|
+
table, in the current directory or above it; `--config` names one instead. Its keys are the
|
|
62
|
+
`check` flags, and a flag or `ODOOSCAN_ADDONS_PATH` replaces the key of the same name.
|
|
63
|
+
|
|
64
|
+
```toml
|
|
65
|
+
[tool.odooscan]
|
|
66
|
+
addons-path = ["../odoo", "../enterprise"]
|
|
67
|
+
odoo-version = "18.0"
|
|
68
|
+
ignore = ["OD111"]
|
|
69
|
+
exclude = ["/legacy", "migrations/"]
|
|
70
|
+
baseline = "odooscan-baseline.json"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Paths in the file are relative to it, and so are anchored `exclude` patterns (those with a slash
|
|
74
|
+
before the end, such as `/legacy`). An unanchored one, such as `migrations/`, matches at any depth.
|
|
75
|
+
Excluded files are still indexed: they only go unreported.
|
|
76
|
+
|
|
77
|
+
## In CI
|
|
78
|
+
|
|
79
|
+
The scan needs the Odoo sources your modules build on. A shallow sparse clone into a hidden
|
|
80
|
+
directory is enough, and module discovery skips hidden directories. On GitHub, `--format github`
|
|
81
|
+
annotates the pull request, with no need for the Advanced Security that SARIF upload requires on a
|
|
82
|
+
private repository:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
- uses: actions/checkout@v7
|
|
86
|
+
- uses: actions/checkout@v7
|
|
87
|
+
with:
|
|
88
|
+
repository: odoo/odoo
|
|
89
|
+
ref: "18.0"
|
|
90
|
+
path: .odoo
|
|
91
|
+
fetch-depth: 1
|
|
92
|
+
sparse-checkout: |
|
|
93
|
+
addons
|
|
94
|
+
odoo/addons
|
|
95
|
+
persist-credentials: false
|
|
96
|
+
- uses: astral-sh/setup-uv@v10
|
|
97
|
+
- run: uvx --from odooscan oscn check --addons-path .odoo --format github
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
On GitLab, `--format gitlab` writes a Code Quality report for the merge request:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
odooscan:
|
|
104
|
+
image: python:3.13
|
|
105
|
+
script:
|
|
106
|
+
- git clone --depth 1 --branch 18.0 --filter=blob:none --sparse https://github.com/odoo/odoo .odoo
|
|
107
|
+
- git -C .odoo sparse-checkout set addons odoo/addons
|
|
108
|
+
- pip install odooscan
|
|
109
|
+
- oscn check --addons-path .odoo --format gitlab > gl-code-quality-report.json
|
|
110
|
+
artifacts:
|
|
111
|
+
when: always
|
|
112
|
+
reports:
|
|
113
|
+
codequality: gl-code-quality-report.json
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Pin `odooscan` to a version, and the actions to commit SHAs, in a real pipeline.
|
|
117
|
+
|
|
118
|
+
## Series
|
|
119
|
+
|
|
120
|
+
Each rule declares the Odoo series it applies to, and every module is checked against its own
|
|
121
|
+
series. The series is the first two parts of a five-part manifest version, so `18.0.1.2.0` means
|
|
122
|
+
18.0. Pass `--odoo-version 18.0` for modules whose version does not name one. Those modules
|
|
123
|
+
otherwise get only the rules that carry no range. `oscn rules --odoo-version 18.0` lists the
|
|
124
|
+
rules for a series.
|
|
125
|
+
|
|
126
|
+
## Adopting on an existing codebase
|
|
127
|
+
|
|
128
|
+
`oscn check --write-baseline` records every current finding in `odooscan-baseline.json` beside the
|
|
129
|
+
configuration file, and later runs given `--baseline odooscan-baseline.json` (or the `baseline`
|
|
130
|
+
key) report only new ones. A finding is recorded by file, code and message, not line, so edits
|
|
131
|
+
around it do not bring it back. When findings are fixed, a notice says so; write the baseline again
|
|
132
|
+
to drop them and keep the file shrinking.
|
|
133
|
+
|
|
134
|
+
## Suppressing a finding
|
|
135
|
+
|
|
136
|
+
Write `odooscan: ignore[OD103]` in a comment, or `noqa: OD103`. A trailing comment covers its own
|
|
137
|
+
line, and a comment alone on a line covers the next one. `odooscan: ignore` without codes covers
|
|
138
|
+
every rule. XML takes the same text inside `<!-- -->`.
|
|
139
|
+
|
|
140
|
+
## Layout
|
|
141
|
+
|
|
142
|
+
- `crates/odooscan_core/src/project.rs` finds modules, parses every file in parallel, and keeps
|
|
143
|
+
per-file facts.
|
|
144
|
+
- `python.rs`, `xml.rs`, `csvdata.rs` and `manifest.rs` extract those facts and raise the
|
|
145
|
+
single-file rules.
|
|
146
|
+
- `index.rs` merges the facts. It resolves fields through `_inherit`, `_inherits` and
|
|
147
|
+
`delegate=True`, related comodels, view inheritance, and the dependency scope of each module.
|
|
148
|
+
- `checks.rs` holds the cross-file rules.
|
|
149
|
+
- `rules.rs` is the registry: code, series range, severity and category.
|
|
150
|
+
- `crates/odooscan` is the CLI.
|
|
151
|
+
|
|
152
|
+
## Testing
|
|
153
|
+
|
|
154
|
+
`cargo test` runs a snapshot over `crates/odooscan_core/tests/fixtures`. That fixture is a small
|
|
155
|
+
core (`base`, `mail`) plus custom modules written to trigger every rule; review changes with
|
|
156
|
+
`cargo insta review`. The false-positive oracle is Odoo itself. A scan of Odoo core must stay
|
|
157
|
+
near-silent for the index-aware rules, so run one after any change to them:
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
git -C ~/repos/odoo/odoo archive origin/18.0 -- addons odoo/addons ':(exclude,glob)**/static/**' | tar -x -C /tmp/odoo-18.0
|
|
161
|
+
oscn check /tmp/odoo-18.0 --odoo-version 18.0 --statistics
|
|
162
|
+
```
|
|
163
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
odooscan-0.2.0.data/scripts/oscn.exe,sha256=Ct58HzF5G38HZqxuGh0AuaHacxpypt141x1_S4DfzFQ,4858368
|
|
2
|
+
odooscan-0.2.0.dist-info/METADATA,sha256=fi-0CP30LmG9sdiEPyHSEx4bMklEK0OkEx_XzCaNkrk,7466
|
|
3
|
+
odooscan-0.2.0.dist-info/WHEEL,sha256=8Aej0W0a6Cz6apA3IzJrTnxLRVLAt-w0Oh8SA3Con_c,94
|
|
4
|
+
odooscan-0.2.0.dist-info/licenses/LICENSE,sha256=huA5Cm2O3t3c2YDNjTrXfcwIbbF7s1VlVR_YGtNsuO4,1086
|
|
5
|
+
odooscan-0.2.0.dist-info/sboms/odooscan.cyclonedx.json,sha256=tGyLaJkfr7utDe1GS8LbkWE0Pmq1TXXBCyFA31eokbE,124324
|
|
6
|
+
odooscan-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Avanserv
|
|
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.
|