vintar 0.1.0__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.
- vintar/__init__.py +2 -0
- vintar/checks/__init__.py +0 -0
- vintar/checks/sqli/__init__.py +0 -0
- vintar/checks/sqli/_errors.py +27 -0
- vintar/checks/sqli/_time_evidence_posix.py +186 -0
- vintar/checks/sqli/analyzer.py +180 -0
- vintar/checks/sqli/confirmation.py +348 -0
- vintar/checks/sqli/confirmation_runner.py +640 -0
- vintar/checks/sqli/cross_phase.py +141 -0
- vintar/checks/sqli/dynamic.py +90 -0
- vintar/checks/sqli/models.py +225 -0
- vintar/checks/sqli/orchestrator.py +194 -0
- vintar/checks/sqli/presets.py +46 -0
- vintar/checks/sqli/report.py +99 -0
- vintar/checks/sqli/time_analyzer.py +477 -0
- vintar/checks/sqli/time_application_quality.py +325 -0
- vintar/checks/sqli/time_cluster_quality.py +286 -0
- vintar/checks/sqli/time_evidence.py +236 -0
- vintar/checks/sqli/time_evidence_audit.py +393 -0
- vintar/checks/sqli/time_evidence_checkpoint.py +269 -0
- vintar/checks/sqli/time_evidence_freshness.py +211 -0
- vintar/checks/sqli/time_evidence_governor.py +729 -0
- vintar/checks/sqli/time_evidence_lifecycle.py +284 -0
- vintar/checks/sqli/time_evidence_loader.py +70 -0
- vintar/checks/sqli/time_evidence_process.py +355 -0
- vintar/checks/sqli/time_evidence_session.py +292 -0
- vintar/checks/sqli/time_evidence_signature.py +297 -0
- vintar/checks/sqli/time_evidence_stream.py +347 -0
- vintar/checks/sqli/time_plan.py +270 -0
- vintar/checks/sqli/time_provenance.py +305 -0
- vintar/checks/sqli/time_quality.py +521 -0
- vintar/checks/sqli/time_research.py +375 -0
- vintar/checks/sqli/time_runner.py +317 -0
- vintar/cli.py +163 -0
- vintar/core/__init__.py +0 -0
- vintar/core/budget.py +43 -0
- vintar/core/executor.py +142 -0
- vintar/core/http.py +88 -0
- vintar/core/injector.py +48 -0
- vintar/core/models.py +14 -0
- vintar/core/rate_limit.py +75 -0
- vintar/core/request.py +36 -0
- vintar/core/scope.py +98 -0
- vintar/core/template.py +120 -0
- vintar/core/transport.py +149 -0
- vintar/discover_cli.py +177 -0
- vintar/materialize_case_cli.py +58 -0
- vintar/regression/__init__.py +51 -0
- vintar/regression/batch.py +202 -0
- vintar/regression/binding.py +93 -0
- vintar/regression/case_materialization.py +406 -0
- vintar/regression/cases.py +503 -0
- vintar/regression/discovery.py +991 -0
- vintar/regression/discovery_drafts.py +161 -0
- vintar/regression/discovery_review.py +312 -0
- vintar/regression/report.py +129 -0
- vintar/regression/runner.py +262 -0
- vintar/regression_cli.py +223 -0
- vintar/review_draft_cli.py +52 -0
- vintar/sqli_cli.py +170 -0
- vintar-0.1.0.dist-info/METADATA +375 -0
- vintar-0.1.0.dist-info/RECORD +65 -0
- vintar-0.1.0.dist-info/WHEEL +4 -0
- vintar-0.1.0.dist-info/entry_points.txt +3 -0
- vintar-0.1.0.dist-info/licenses/LICENSE +202 -0
vintar/__init__.py
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Keep internal verification failures out of public diagnostics."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Iterator
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class _UnexpectedVerificationError(Exception):
|
|
8
|
+
"""An unexpected failure at a verification boundary."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@contextmanager
|
|
12
|
+
def redact_runtime_errors(
|
|
13
|
+
message: str,
|
|
14
|
+
*,
|
|
15
|
+
passthrough: tuple[type[Exception], ...] = (),
|
|
16
|
+
) -> Iterator[None]:
|
|
17
|
+
try:
|
|
18
|
+
try:
|
|
19
|
+
yield
|
|
20
|
+
except passthrough:
|
|
21
|
+
raise
|
|
22
|
+
except (TypeError, ValueError):
|
|
23
|
+
raise RuntimeError(message) from None
|
|
24
|
+
except Exception as exc:
|
|
25
|
+
raise _UnexpectedVerificationError(message) from exc
|
|
26
|
+
except _UnexpectedVerificationError:
|
|
27
|
+
raise RuntimeError(message) from None
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"""Shared descriptor-relative POSIX acquisition boundary for local evidence.
|
|
2
|
+
|
|
3
|
+
The caller performs platform capability checks. This internal module
|
|
4
|
+
provides confinement and metadata consistency, not an atomic snapshot.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import stat
|
|
9
|
+
from collections.abc import Callable, Iterator
|
|
10
|
+
from contextlib import ExitStack, contextmanager
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
from vintar.checks.sqli.time_evidence import MAX_EVIDENCE_BYTES
|
|
14
|
+
|
|
15
|
+
MAX_CHUNK_SIZE = 64 * 1024
|
|
16
|
+
_MAX_ROOT_DEPTH = 64
|
|
17
|
+
_MAX_ROOT_PATH_LENGTH = 4096
|
|
18
|
+
_MAX_DEPTH = 16
|
|
19
|
+
_MAX_RELATIVE_PATH_LENGTH = 1024
|
|
20
|
+
_SAFE_FILENAME_CHARS = frozenset(
|
|
21
|
+
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.-"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class EvidenceAcquisitionError(RuntimeError):
|
|
26
|
+
"""Evidence could not be acquired under the local safety policy."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def require_posix() -> None:
|
|
30
|
+
required = ("O_DIRECTORY", "O_NOFOLLOW", "O_CLOEXEC", "O_NONBLOCK")
|
|
31
|
+
if os.name != "posix" or any(not hasattr(os, name) for name in required):
|
|
32
|
+
raise EvidenceAcquisitionError(
|
|
33
|
+
"Secure local evidence acquisition is unsupported."
|
|
34
|
+
)
|
|
35
|
+
if (
|
|
36
|
+
os.open not in os.supports_dir_fd
|
|
37
|
+
or os.stat not in os.supports_dir_fd
|
|
38
|
+
or os.stat not in os.supports_follow_symlinks
|
|
39
|
+
):
|
|
40
|
+
raise EvidenceAcquisitionError(
|
|
41
|
+
"Directory-relative file opening is unsupported."
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def root_components(root: str | Path) -> tuple[str, ...]:
|
|
46
|
+
if isinstance(root, Path):
|
|
47
|
+
value = str(root)
|
|
48
|
+
elif type(root) is str:
|
|
49
|
+
value = root
|
|
50
|
+
else:
|
|
51
|
+
raise TypeError("Invalid evidence root.")
|
|
52
|
+
if (
|
|
53
|
+
not value.startswith("/")
|
|
54
|
+
or value == "/"
|
|
55
|
+
or len(value) > _MAX_ROOT_PATH_LENGTH
|
|
56
|
+
or "\x00" in value
|
|
57
|
+
or value.endswith("/")
|
|
58
|
+
or "//" in value
|
|
59
|
+
):
|
|
60
|
+
raise ValueError("Invalid evidence root.")
|
|
61
|
+
components = tuple(value[1:].split("/"))
|
|
62
|
+
if not 1 <= len(components) <= _MAX_ROOT_DEPTH or any(
|
|
63
|
+
component in ("", ".", "..") or len(component) > 255 for component in components
|
|
64
|
+
):
|
|
65
|
+
raise ValueError("Invalid evidence root.")
|
|
66
|
+
return components
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def relative_components(relative_path: str) -> tuple[str, ...]:
|
|
70
|
+
if type(relative_path) is not str:
|
|
71
|
+
raise TypeError("Invalid relative evidence path.")
|
|
72
|
+
if not 1 <= len(relative_path) <= _MAX_RELATIVE_PATH_LENGTH:
|
|
73
|
+
raise ValueError("Invalid relative evidence path.")
|
|
74
|
+
components = tuple(relative_path.split("/"))
|
|
75
|
+
if not 1 <= len(components) <= _MAX_DEPTH:
|
|
76
|
+
raise ValueError("Invalid relative evidence path.")
|
|
77
|
+
if any(
|
|
78
|
+
not component
|
|
79
|
+
or component in (".", "..")
|
|
80
|
+
or len(component) > 100
|
|
81
|
+
or any(character not in _SAFE_FILENAME_CHARS for character in component)
|
|
82
|
+
for component in components
|
|
83
|
+
):
|
|
84
|
+
raise ValueError("Invalid relative evidence path.")
|
|
85
|
+
return components
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _directory_flags() -> int:
|
|
89
|
+
return os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW | os.O_CLOEXEC
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _file_flags() -> int:
|
|
93
|
+
return (
|
|
94
|
+
os.O_RDONLY
|
|
95
|
+
| os.O_NOFOLLOW
|
|
96
|
+
| os.O_CLOEXEC
|
|
97
|
+
| os.O_NONBLOCK
|
|
98
|
+
| getattr(os, "O_NOCTTY", 0)
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def stable_file(before: os.stat_result, after: os.stat_result) -> bool:
|
|
103
|
+
attributes = (
|
|
104
|
+
"st_dev",
|
|
105
|
+
"st_ino",
|
|
106
|
+
"st_mode",
|
|
107
|
+
"st_nlink",
|
|
108
|
+
"st_size",
|
|
109
|
+
"st_mtime_ns",
|
|
110
|
+
"st_ctime_ns",
|
|
111
|
+
)
|
|
112
|
+
return all(getattr(before, name) == getattr(after, name) for name in attributes)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def validate_file_metadata(metadata: os.stat_result) -> None:
|
|
116
|
+
if not stat.S_ISREG(metadata.st_mode):
|
|
117
|
+
raise EvidenceAcquisitionError("Evidence is not a regular file.")
|
|
118
|
+
if metadata.st_nlink != 1:
|
|
119
|
+
raise EvidenceAcquisitionError("Evidence has an unsupported link count.")
|
|
120
|
+
if not 1 <= metadata.st_size <= MAX_EVIDENCE_BYTES:
|
|
121
|
+
raise EvidenceAcquisitionError(
|
|
122
|
+
"Evidence file size is outside the allowed range."
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@contextmanager
|
|
127
|
+
def managed_fd(fd: int) -> Iterator[int]:
|
|
128
|
+
try:
|
|
129
|
+
yield fd
|
|
130
|
+
finally:
|
|
131
|
+
os.close(fd)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@contextmanager
|
|
135
|
+
def open_confined_evidence(
|
|
136
|
+
*,
|
|
137
|
+
root: str | Path,
|
|
138
|
+
relative_path: str,
|
|
139
|
+
checkpoint: Callable[[], None] | None = None,
|
|
140
|
+
pre_open_check: Callable[[os.stat_result], None] | None = None,
|
|
141
|
+
) -> Iterator[tuple[int, os.stat_result]]:
|
|
142
|
+
"""Yield a validated regular-file FD and its pre-read metadata.
|
|
143
|
+
|
|
144
|
+
The descriptor remains owned by this context manager. The caller must
|
|
145
|
+
finish reading and call validate_after_read before leaving the scope.
|
|
146
|
+
"""
|
|
147
|
+
roots = root_components(root)
|
|
148
|
+
parts = relative_components(relative_path)
|
|
149
|
+
|
|
150
|
+
def check() -> None:
|
|
151
|
+
if checkpoint is not None:
|
|
152
|
+
checkpoint()
|
|
153
|
+
|
|
154
|
+
with ExitStack() as stack:
|
|
155
|
+
check()
|
|
156
|
+
directory_fd = stack.enter_context(managed_fd(os.open("/", _directory_flags())))
|
|
157
|
+
for component in (*roots, *parts[:-1]):
|
|
158
|
+
check()
|
|
159
|
+
directory_fd = stack.enter_context(
|
|
160
|
+
managed_fd(os.open(component, _directory_flags(), dir_fd=directory_fd))
|
|
161
|
+
)
|
|
162
|
+
check()
|
|
163
|
+
path_metadata = os.stat(parts[-1], dir_fd=directory_fd, follow_symlinks=False)
|
|
164
|
+
validate_file_metadata(path_metadata)
|
|
165
|
+
if pre_open_check is not None:
|
|
166
|
+
pre_open_check(path_metadata)
|
|
167
|
+
check()
|
|
168
|
+
file_fd = stack.enter_context(
|
|
169
|
+
managed_fd(os.open(parts[-1], _file_flags(), dir_fd=directory_fd))
|
|
170
|
+
)
|
|
171
|
+
before = os.fstat(file_fd)
|
|
172
|
+
validate_file_metadata(before)
|
|
173
|
+
if not stable_file(path_metadata, before):
|
|
174
|
+
raise EvidenceAcquisitionError("Evidence changed during acquisition.")
|
|
175
|
+
if pre_open_check is not None:
|
|
176
|
+
pre_open_check(before)
|
|
177
|
+
yield file_fd, before
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def validate_after_read(*, file_fd: int, before: os.stat_result, received: int) -> None:
|
|
181
|
+
"""Check metadata stability and exact byte count after a bounded read."""
|
|
182
|
+
after = os.fstat(file_fd)
|
|
183
|
+
if not stable_file(before, after):
|
|
184
|
+
raise EvidenceAcquisitionError("Evidence changed during acquisition.")
|
|
185
|
+
if received != before.st_size:
|
|
186
|
+
raise EvidenceAcquisitionError("Evidence length changed during acquisition.")
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import hashlib
|
|
2
|
+
|
|
3
|
+
from vintar.checks.sqli.dynamic import detect_dynamic_region
|
|
4
|
+
from vintar.checks.sqli.models import (
|
|
5
|
+
BooleanEvidence,
|
|
6
|
+
Observation,
|
|
7
|
+
ProbeKind,
|
|
8
|
+
Verdict,
|
|
9
|
+
VerificationResult,
|
|
10
|
+
)
|
|
11
|
+
from vintar.core.models import HttpResult
|
|
12
|
+
|
|
13
|
+
type ResponsePair = tuple[HttpResult, HttpResult]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _validate_response_pair(name: str, responses: object) -> ResponsePair:
|
|
17
|
+
"""Validate the two completed responses required for one probe kind."""
|
|
18
|
+
if not isinstance(responses, tuple):
|
|
19
|
+
raise TypeError(f"{name} must be a tuple.")
|
|
20
|
+
if len(responses) != 2:
|
|
21
|
+
raise ValueError(f"{name} must contain exactly two responses.")
|
|
22
|
+
if not all(isinstance(response, HttpResult) for response in responses):
|
|
23
|
+
raise TypeError(f"{name} must contain HttpResult objects.")
|
|
24
|
+
if not all(type(response.body) is bytes for response in responses):
|
|
25
|
+
raise TypeError(f"{name} response bodies must be bytes.")
|
|
26
|
+
|
|
27
|
+
return responses
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _matches(left: HttpResult, right: HttpResult) -> bool:
|
|
31
|
+
"""Compare status and full captured response body."""
|
|
32
|
+
return left.status_code == right.status_code and left.body == right.body
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def _stable(responses: ResponsePair) -> bool:
|
|
36
|
+
"""Require both attempts to produce identical content."""
|
|
37
|
+
return _matches(responses[0], responses[1])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _observation(
|
|
41
|
+
kind: ProbeKind,
|
|
42
|
+
response: HttpResult,
|
|
43
|
+
) -> Observation:
|
|
44
|
+
return Observation(
|
|
45
|
+
kind=kind,
|
|
46
|
+
status_code=response.status_code,
|
|
47
|
+
body_size=response.size,
|
|
48
|
+
elapsed=response.elapsed,
|
|
49
|
+
body_digest=hashlib.sha256(response.body).hexdigest(),
|
|
50
|
+
truncated=response.truncated,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def analyze_boolean_responses(
|
|
55
|
+
check_id: str,
|
|
56
|
+
baseline: ResponsePair,
|
|
57
|
+
true_responses: ResponsePair,
|
|
58
|
+
false_responses: ResponsePair,
|
|
59
|
+
) -> VerificationResult:
|
|
60
|
+
"""Analyze six completed, authorized Boolean SQLi probes.
|
|
61
|
+
|
|
62
|
+
This function performs no HTTP requests.
|
|
63
|
+
All six requests must have completed successfully.
|
|
64
|
+
"""
|
|
65
|
+
baseline = _validate_response_pair("baseline", baseline)
|
|
66
|
+
true_responses = _validate_response_pair("true_responses", true_responses)
|
|
67
|
+
false_responses = _validate_response_pair("false_responses", false_responses)
|
|
68
|
+
|
|
69
|
+
groups = (
|
|
70
|
+
(ProbeKind.BASELINE, baseline),
|
|
71
|
+
(ProbeKind.TRUE, true_responses),
|
|
72
|
+
(ProbeKind.FALSE, false_responses),
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
observations = tuple(
|
|
76
|
+
_observation(kind, response)
|
|
77
|
+
for kind, responses in groups
|
|
78
|
+
for response in responses
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
def result(
|
|
82
|
+
verdict: Verdict,
|
|
83
|
+
reason_code: str,
|
|
84
|
+
reason: str,
|
|
85
|
+
evidence: BooleanEvidence | None = None,
|
|
86
|
+
) -> VerificationResult:
|
|
87
|
+
return VerificationResult(
|
|
88
|
+
check_id=check_id,
|
|
89
|
+
verdict=verdict,
|
|
90
|
+
observations=observations,
|
|
91
|
+
request_count=len(observations),
|
|
92
|
+
reason_code=reason_code,
|
|
93
|
+
reason=reason,
|
|
94
|
+
evidence=evidence,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if any(item.truncated for item in observations):
|
|
98
|
+
return result(
|
|
99
|
+
Verdict.INCONCLUSIVE,
|
|
100
|
+
"truncated_response",
|
|
101
|
+
"At least one response was truncated.",
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
if any(not 200 <= item.status_code < 300 for item in observations):
|
|
105
|
+
return result(
|
|
106
|
+
Verdict.INCONCLUSIVE,
|
|
107
|
+
"non_success_status",
|
|
108
|
+
"At least one probe returned a non-2xx HTTP status.",
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
unstable_pairs = [responses for _, responses in groups if not _stable(responses)]
|
|
112
|
+
|
|
113
|
+
if unstable_pairs:
|
|
114
|
+
possible_dynamic = all(
|
|
115
|
+
detect_dynamic_region(responses[0], responses[1]) is not None
|
|
116
|
+
for responses in unstable_pairs
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
if possible_dynamic:
|
|
120
|
+
return result(
|
|
121
|
+
Verdict.INCONCLUSIVE,
|
|
122
|
+
"possible_dynamic_response",
|
|
123
|
+
"Repeated probes contain small localized "
|
|
124
|
+
"differences; no Boolean conclusion was made.",
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
return result(
|
|
128
|
+
Verdict.INCONCLUSIVE,
|
|
129
|
+
"unstable_response",
|
|
130
|
+
"Repeated probes produced different responses.",
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
baseline_response = baseline[0]
|
|
134
|
+
true_response = true_responses[0]
|
|
135
|
+
false_response = false_responses[0]
|
|
136
|
+
|
|
137
|
+
baseline_true = _matches(baseline_response, true_response)
|
|
138
|
+
baseline_false = _matches(baseline_response, false_response)
|
|
139
|
+
true_false = _matches(true_response, false_response)
|
|
140
|
+
|
|
141
|
+
evidence = BooleanEvidence(
|
|
142
|
+
baseline_true_similarity=float(baseline_true),
|
|
143
|
+
baseline_false_similarity=float(baseline_false),
|
|
144
|
+
true_false_similarity=float(true_false),
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
if baseline_true and baseline_false:
|
|
148
|
+
return result(
|
|
149
|
+
Verdict.NOT_DETECTED,
|
|
150
|
+
"no_boolean_difference",
|
|
151
|
+
"No Boolean response difference was detected in these six probes; "
|
|
152
|
+
"this does not prove the target is not vulnerable.",
|
|
153
|
+
evidence,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
if baseline_true and not baseline_false:
|
|
157
|
+
return result(
|
|
158
|
+
Verdict.INCONCLUSIVE,
|
|
159
|
+
"boolean_candidate",
|
|
160
|
+
"Reproducible Boolean differential detected; "
|
|
161
|
+
"additional verification is required.",
|
|
162
|
+
evidence,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
if true_false:
|
|
166
|
+
return result(
|
|
167
|
+
Verdict.NOT_DETECTED,
|
|
168
|
+
"no_boolean_difference_literal_input",
|
|
169
|
+
"The stable TRUE and FALSE probes produced identical responses while "
|
|
170
|
+
"both differed from the baseline. No Boolean differential was detected; "
|
|
171
|
+
"check whether the target treats injected payloads as literal input.",
|
|
172
|
+
evidence,
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
return result(
|
|
176
|
+
Verdict.INCONCLUSIVE,
|
|
177
|
+
"unexpected_difference",
|
|
178
|
+
"Responses differ without the expected Boolean pattern.",
|
|
179
|
+
evidence,
|
|
180
|
+
)
|