tomte 0.7.2__tar.gz → 0.7.3__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.
Files changed (29) hide show
  1. {tomte-0.7.2 → tomte-0.7.3}/PKG-INFO +10 -2
  2. {tomte-0.7.2 → tomte-0.7.3}/README.md +8 -1
  3. {tomte-0.7.2 → tomte-0.7.3}/pyproject.toml +1 -1
  4. tomte-0.7.3/tomte/__init__.py +1 -0
  5. tomte-0.7.3/tomte/configs/safety-policy.yml +24 -0
  6. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/tox.ini +3 -1
  7. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/tox_runtime.py +45 -0
  8. tomte-0.7.2/tomte/__init__.py +0 -1
  9. tomte-0.7.2/tomte/configs/safety-policy.yml +0 -12
  10. {tomte-0.7.2 → tomte-0.7.3}/LICENSE +0 -0
  11. {tomte-0.7.2 → tomte-0.7.3}/tomte/cli.py +0 -0
  12. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/__init__.py +0 -0
  13. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/bandit.yaml +0 -0
  14. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/darglint.cfg +0 -0
  15. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/flake8.cfg +0 -0
  16. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/gitleaks.toml +0 -0
  17. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/isort.cfg +0 -0
  18. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/mypy.ini +0 -0
  19. {tomte-0.7.2 → tomte-0.7.3}/tomte/configs/pylintrc +0 -0
  20. {tomte-0.7.2 → tomte-0.7.3}/tomte/pytest_plugin.py +0 -0
  21. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/__init__.py +0 -0
  22. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/check_copyright.py +0 -0
  23. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/check_doc_links.py +0 -0
  24. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/check_readme.py +0 -0
  25. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/freeze_dependencies.py +0 -0
  26. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/freeze_gitleaks.py +0 -0
  27. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/packages_json.py +0 -0
  28. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/render_isort_config.py +0 -0
  29. {tomte-0.7.2 → tomte-0.7.3}/tomte/tools/render_mypy_config.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tomte
3
- Version: 0.7.2
3
+ Version: 0.7.3
4
4
  Summary: A library that wraps many useful tools (linters, analysers, etc) to keep Python code clean, secure, well-documented and optimised.
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -14,6 +14,7 @@ Classifier: Programming Language :: Python :: 3.11
14
14
  Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Programming Language :: Python :: 3.15
17
18
  Provides-Extra: bandit
18
19
  Provides-Extra: black
19
20
  Provides-Extra: cli
@@ -123,7 +124,14 @@ drop-in replacement: `tomte tox -e <env>`.
123
124
  `known_first_party`, `open_autonomy_version`, `open_aea_version`,
124
125
  `check_handlers_ignores`, `check_dependencies_extra_excludes`,
125
126
  `upstream_pins`, `gitleaks_extra_paths`, `gitleaks_extra_regexes`,
126
- `tomte_dep_pin`. Most defaults auto-derive from `packages.json`.
127
+ `safety_ignores`, `tomte_dep_pin`. Most defaults auto-derive from
128
+ `packages.json`.
129
+
130
+ `safety_ignores` takes an advisory id or a list of them and renders them
131
+ as `--ignore` flags on the `safety` scan, after the fleet baseline in
132
+ `_FLEET_SAFETY_IGNORES`. Add an entry only when the vulnerable code is
133
+ unreachable from the scan, and record why alongside it. An unavailable
134
+ fix is a reason an entry cannot be retired yet, not a reason to add one.
127
135
 
128
136
  `service_public_id` takes a single public id or a list of them, and
129
137
  `[testenv:analyse-service]` runs `autonomy analyse service` once per
@@ -55,7 +55,14 @@ drop-in replacement: `tomte tox -e <env>`.
55
55
  `known_first_party`, `open_autonomy_version`, `open_aea_version`,
56
56
  `check_handlers_ignores`, `check_dependencies_extra_excludes`,
57
57
  `upstream_pins`, `gitleaks_extra_paths`, `gitleaks_extra_regexes`,
58
- `tomte_dep_pin`. Most defaults auto-derive from `packages.json`.
58
+ `safety_ignores`, `tomte_dep_pin`. Most defaults auto-derive from
59
+ `packages.json`.
60
+
61
+ `safety_ignores` takes an advisory id or a list of them and renders them
62
+ as `--ignore` flags on the `safety` scan, after the fleet baseline in
63
+ `_FLEET_SAFETY_IGNORES`. Add an entry only when the vulnerable code is
64
+ unreachable from the scan, and record why alongside it. An unavailable
65
+ fix is a reason an entry cannot be retired yet, not a reason to add one.
59
66
 
60
67
  `service_public_id` takes a single public id or a list of them, and
61
68
  `[testenv:analyse-service]` runs `autonomy analyse service` once per
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tomte"
3
- version = "0.7.2"
3
+ version = "0.7.3"
4
4
  description = "A library that wraps many useful tools (linters, analysers, etc) to keep Python code clean, secure, well-documented and optimised."
5
5
  authors = ["David Minarsch <david.minarsch@googlemail.com>"]
6
6
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "0.7.3"
@@ -0,0 +1,24 @@
1
+ # Canonical safety policy shipped by tomte.
2
+ #
3
+ # Repos consume this via:
4
+ # safety check --policy-file $(python -c "from tomte.configs import SAFETY_POLICY; print(SAFETY_POLICY)")
5
+ #
6
+ # `ignore-vulnerabilities` below is inert, and adding entries to it does
7
+ # nothing, for two reasons:
8
+ #
9
+ # * safety's `check` validates its keys as positive integers and rejects the
10
+ # `SFTY-<date>-<n>` form advisories are published under
11
+ # * safety reads it only when no `--ignore` flag is given, and `tomte tox`
12
+ # always passes the fleet baseline as flags
13
+ #
14
+ # Ignores are therefore `--ignore` flags rendered by `tomte tox`: the fleet
15
+ # baseline in `_FLEET_SAFETY_IGNORES` (tomte/tools/tox_runtime.py) plus a
16
+ # repo's own `safety_ignores` in `[tool.tomte]`.
17
+ #
18
+ # Coverage: [testenv:safety] installs only safety, so the scan inspects the
19
+ # scanner's own virtualenv and reports nothing about the consuming repo's
20
+ # dependencies. Tracked in https://github.com/valory-xyz/tomte/issues/61.
21
+
22
+ security:
23
+ ignore-vulnerabilities: {}
24
+ continue-on-vulnerability-error: false
@@ -25,6 +25,8 @@
25
25
  ; (e.g. "--ignored-modules=web3 --disable=C0111"),
26
26
  ; or empty when no extras declared
27
27
  ; $$CHECK_HANDLERS_IGNORES check-handlers `-i pkg` ignore flags
28
+ ; $$SAFETY_IGNORES safety `--ignore <id>` flags: the fleet
29
+ ; baseline plus [tool.tomte].safety_ignores
28
30
  ; $$TOMTE_DEP_PIN PEP 508 spec right of `tomte[<extras>]`,
29
31
  ; typically `==0.7.0` or ` @ git+...`
30
32
  ;
@@ -202,7 +204,7 @@ deps =
202
204
  httpx<0.28
203
205
  tomte[safety]$TOMTE_DEP_PIN
204
206
  commands =
205
- safety check --policy-file {envsitepackagesdir}/tomte/configs/safety-policy.yml
207
+ safety check --policy-file {envsitepackagesdir}/tomte/configs/safety-policy.yml $SAFETY_IGNORES
206
208
 
207
209
  ; -- autonomy / aea checks -----------------------------------------------
208
210
 
@@ -19,6 +19,7 @@ import re
19
19
  import shutil
20
20
  import subprocess
21
21
  import sys
22
+ from datetime import date
22
23
  from pathlib import Path
23
24
  from string import Template
24
25
  from typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Union
@@ -45,6 +46,22 @@ from tomte.tools.packages_json import (
45
46
  # moved here because they never vary across consumers downstream of OA.
46
47
  _KNOWN_FIRST_PARTY = "autonomy"
47
48
 
49
+ # Advisories in the safety scanner's own dependency tree, passed to the scan
50
+ # as `--ignore` flags, each mapped to the date its entry must be re-justified
51
+ # by. `[testenv:safety]` installs only safety, so its env holds nothing else.
52
+ # The rule for adding an entry is in the README.
53
+ #
54
+ # safety looks ids up verbatim and says nothing when one matches no advisory,
55
+ # so a mistyped id is a silent no-op and the scan fails as if it were absent.
56
+ _FLEET_SAFETY_IGNORES: Dict[str, date] = {
57
+ # nltk, required by safety. Drop when the scan passes without it.
58
+ "SFTY-20260902-58666": date(2027, 1, 5),
59
+ }
60
+
61
+ # What an advisory id may contain. Ids are rendered into a tox command line,
62
+ # where whitespace starts a new argument and braces are substitution syntax.
63
+ _SAFETY_ID_PATTERN = re.compile(r"^[A-Za-z0-9_-]+$")
64
+
48
65
  # Multi-line continuation values need re-indenting after configparser strip.
49
66
  _DEPS_INDENT = 4
50
67
 
@@ -250,6 +267,33 @@ def _render_pylint_flags(extensions: Dict[str, str], identity: Dict[str, Any]) -
250
267
  return " ".join(flags)
251
268
 
252
269
 
270
+ def _resolve_safety_ignores(identity: Dict[str, Any]) -> str:
271
+ """`--ignore <id>` flags: the fleet baseline, then `safety_ignores`."""
272
+ explicit = identity.get("safety_ignores")
273
+ if explicit is None:
274
+ declared: List[Any] = []
275
+ elif isinstance(explicit, str):
276
+ declared = [explicit]
277
+ elif isinstance(explicit, list):
278
+ declared = explicit
279
+ else:
280
+ raise click.UsageError(
281
+ f"[tool.tomte] safety_ignores must be a string or a list of "
282
+ f"strings, got {type(explicit).__name__}."
283
+ )
284
+ ids: List[str] = list(_FLEET_SAFETY_IGNORES)
285
+ for index, entry in enumerate(declared):
286
+ advisory = entry.strip() if isinstance(entry, str) else ""
287
+ if not _SAFETY_ID_PATTERN.match(advisory):
288
+ raise click.UsageError(
289
+ f"[tool.tomte] safety_ignores entry {index} is not an advisory "
290
+ f"id ({entry!r}); expected letters, digits, `-` and `_` only."
291
+ )
292
+ if advisory not in ids:
293
+ ids.append(advisory)
294
+ return " ".join(f"--ignore {advisory}" for advisory in ids)
295
+
296
+
253
297
  def _join_listish(value: Union[str, Sequence[str]]) -> str:
254
298
  if isinstance(value, str):
255
299
  return value
@@ -693,6 +737,7 @@ def _build_substitutions(
693
737
  "CHECK_DEPENDENCIES_EXTRA_EXCLUDES": _resolve_check_dependencies_extra_excludes(
694
738
  identity
695
739
  ),
740
+ "SAFETY_IGNORES": _resolve_safety_ignores(identity),
696
741
  "EXTRA_DEPS_PACKAGES": _reindent(
697
742
  _resolve_extra_deps(pyproject, extensions), _DEPS_INDENT
698
743
  ),
@@ -1 +0,0 @@
1
- __version__ = "0.7.2"
@@ -1,12 +0,0 @@
1
- # Canonical safety policy shipped by tomte.
2
- #
3
- # Repos consume this via:
4
- # safety check --policy-file $(python -c "from tomte.configs import SAFETY_POLICY; print(SAFETY_POLICY)")
5
- #
6
- # Vulnerability allowlist — repos extend with their own ignores by
7
- # composing a per-repo policy file when needed. The fleet's baseline is
8
- # "fail on any unfixed CVE", so this list stays empty by default.
9
-
10
- security:
11
- ignore-vulnerabilities: {}
12
- continue-on-vulnerability-error: false
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes