bashwalker 0.1.5__py3-none-any.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.
- bashwalker/__init__.py +56 -0
- bashwalker/core.py +2380 -0
- bashwalker-0.1.5.dist-info/METADATA +70 -0
- bashwalker-0.1.5.dist-info/RECORD +8 -0
- bashwalker-0.1.5.dist-info/WHEEL +5 -0
- bashwalker-0.1.5.dist-info/licenses/LICENSE +202 -0
- bashwalker-0.1.5.dist-info/licenses/NOTICE +6 -0
- bashwalker-0.1.5.dist-info/top_level.txt +1 -0
bashwalker/__init__.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""bashwalker: a bash command line in, proven facts per simple command out.
|
|
2
|
+
|
|
3
|
+
``walk(line)`` parses ``line`` with the pinned tree-sitter-bash grammar and returns a
|
|
4
|
+
``Walk``: one ``Invocation`` per simple command (its words, assignments, redirects and
|
|
5
|
+
stdin), every word marked literal or not, and the features that make the tree
|
|
6
|
+
untrusted. It raises ``ParseRefused`` when it cannot prove its facts. It makes no policy
|
|
7
|
+
decision: what a command may do is the caller's to judge, and every unproven fact is
|
|
8
|
+
reported as the worst case so the caller can fail closed.
|
|
9
|
+
|
|
10
|
+
The facts are for one line run on its own in a new, non-interactive shell with no startup
|
|
11
|
+
files and a clean environment (SECURITY.md and architecture section 3.2 give the exact
|
|
12
|
+
conditions). In an interactive shell, or one that has already run other lines, they do
|
|
13
|
+
not hold.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
from bashwalker.core import (
|
|
19
|
+
DEFAULT_LIMITS,
|
|
20
|
+
LANGUAGE,
|
|
21
|
+
Assignment,
|
|
22
|
+
Invocation,
|
|
23
|
+
Limits,
|
|
24
|
+
ParseRefused,
|
|
25
|
+
Redirect,
|
|
26
|
+
Stdin,
|
|
27
|
+
Walk,
|
|
28
|
+
Word,
|
|
29
|
+
command_head,
|
|
30
|
+
lex_word,
|
|
31
|
+
make_word,
|
|
32
|
+
may_rewire_stdin,
|
|
33
|
+
parse_source,
|
|
34
|
+
untrusted_features,
|
|
35
|
+
walk,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"DEFAULT_LIMITS",
|
|
40
|
+
"LANGUAGE",
|
|
41
|
+
"Assignment",
|
|
42
|
+
"Invocation",
|
|
43
|
+
"Limits",
|
|
44
|
+
"ParseRefused",
|
|
45
|
+
"Redirect",
|
|
46
|
+
"Stdin",
|
|
47
|
+
"Walk",
|
|
48
|
+
"Word",
|
|
49
|
+
"command_head",
|
|
50
|
+
"lex_word",
|
|
51
|
+
"make_word",
|
|
52
|
+
"may_rewire_stdin",
|
|
53
|
+
"parse_source",
|
|
54
|
+
"untrusted_features",
|
|
55
|
+
"walk",
|
|
56
|
+
]
|