timecs 2.0.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.
- app.py +3014 -0
- ast_scanner.py +36187 -0
- banner.py +146 -0
- ci_reporter.py +570 -0
- cli.py +2347 -0
- config_loader.py +307 -0
- cross_file_engine.py +1781 -0
- delivery_models.py +145 -0
- delivery_repository.py +78 -0
- diff_scan.py +127 -0
- durable_delivery_sink.py +103 -0
- event_bus.py +155 -0
- event_publisher.py +345 -0
- event_taxonomy.py +313 -0
- function_summarizer.py +354 -0
- html_auditor.py +274 -0
- iac_auditor.py +400 -0
- in_app_adapter.py +115 -0
- js_scanner.py +895 -0
- manifest_parser.py +960 -0
- master_rules_bank.py +389 -0
- notification_models.py +346 -0
- notification_policy.py +309 -0
- notification_repository.py +118 -0
- notification_routes.py +394 -0
- notification_service.py +199 -0
- osv_client.py +437 -0
- remediation/__init__.py +39 -0
- remediation/base.py +102 -0
- remediation/contracts.py +196 -0
- remediation/cwe1188_binding.py +78 -0
- remediation/cwe1336_jinja.py +91 -0
- remediation/cwe22_path_traversal.py +348 -0
- remediation/cwe295_ssl.py +87 -0
- remediation/cwe327_weak_hash.py +78 -0
- remediation/cwe377_tempfile.py +77 -0
- remediation/cwe489_debug.py +80 -0
- remediation/cwe502_yaml.py +89 -0
- remediation/cwe614_cookie.py +91 -0
- remediation/cwe78_cmdi.py +415 -0
- remediation/cwe798_credentials.py +153 -0
- remediation/cwe89_sqli.py +425 -0
- remediation/cwe916_password_hash.py +131 -0
- remediation/cwe95_eval.py +77 -0
- remediation/dispatcher.py +114 -0
- remediation/orchestrator.py +541 -0
- remediation/patch_engine.py +213 -0
- remediation/verification.py +253 -0
- rule_engine.py +1535 -0
- sarif_adapter.py +719 -0
- sarif_exporter.py +88 -0
- sca_reachability/__init__.py +28 -0
- sca_reachability/ast_analyzer.py +366 -0
- sca_reachability/call_graph.py +203 -0
- sca_reachability/contracts.py +365 -0
- sca_reachability/dist_import_map.py +46 -0
- sca_reachability/engine.py +603 -0
- sca_reachability/resolver.py +169 -0
- scanners/__init__.py +70 -0
- scanners/container_scanner.py +323 -0
- scanners/cve_index.py +521 -0
- scanners/iac_scanner.py +328 -0
- scanners/sbom.py +183 -0
- scanners/sca_scanner.py +667 -0
- scanners/secret_scanner.py +345 -0
- scanners/yaml_lite.py +217 -0
- secret_filters.py +435 -0
- secret_scanner.py +943 -0
- sqlite_delivery_repository.py +277 -0
- sqlite_notification_repository.py +441 -0
- ssrf_guard.py +276 -0
- staged_scanner.py +492 -0
- suppression_resolver.py +282 -0
- symbol_indexer.py +424 -0
- tcs/__init__.py +1 -0
- tcs/analysis/__init__.py +1 -0
- tcs/analysis/def_use.py +408 -0
- tcs/analysis/function_contracts.py +290 -0
- tcs/parallel_analyzer.py +276 -0
- tcs/parallel_scanner.py +630 -0
- tcs/treesitter_packer.py +1446 -0
- tcs_cli.py +2086 -0
- tcs_config.py +218 -0
- tcs_gui.py +2123 -0
- timecs-2.0.0.dist-info/METADATA +142 -0
- timecs-2.0.0.dist-info/RECORD +94 -0
- timecs-2.0.0.dist-info/WHEEL +5 -0
- timecs-2.0.0.dist-info/entry_points.txt +4 -0
- timecs-2.0.0.dist-info/licenses/LICENSE +201 -0
- timecs-2.0.0.dist-info/top_level.txt +49 -0
- version_matcher.py +934 -0
- webhook_adapter.py +495 -0
- webhook_client.py +483 -0
- webhook_formatters.py +245 -0
banner.py
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""Nuclei-style terminal UX for the timecs CLI -- stdlib only, stderr only.
|
|
2
|
+
|
|
3
|
+
stdout is a data pipe: `--format json` consumers parse it, so every line this module produces
|
|
4
|
+
goes to stderr, exactly as nuclei and ripgrep do. The caller decides *whether* to speak (a TTY,
|
|
5
|
+
or TIMECS_FORCE_BANNER for a deterministic test); this module only decides *how* to speak.
|
|
6
|
+
|
|
7
|
+
Two refusals make the output safe on any terminal:
|
|
8
|
+
|
|
9
|
+
* Colour is emitted only when the stream is a TTY and NO_COLOR is unset. A redirected log or a
|
|
10
|
+
CI capture gets the bare `[INF]` tag, never an escape sequence it would store as litter.
|
|
11
|
+
* Every non-ASCII glyph is probed against the stream's own encoding before it is chosen. Windows
|
|
12
|
+
consoles still default to cp1252, which cannot encode the box-drawing rule or the arrow, so
|
|
13
|
+
those fall back to `-` and `->`. The probe covers exactly the characters about to be written,
|
|
14
|
+
which is what makes a UnicodeEncodeError unreachable from here.
|
|
15
|
+
|
|
16
|
+
The wordmark is TIMECS and the command is `timecs`; the art is 46 columns so it never wraps on
|
|
17
|
+
an 80-column terminal.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
import os
|
|
23
|
+
import sys
|
|
24
|
+
from typing import Any, Optional
|
|
25
|
+
|
|
26
|
+
__all__ = ["VERSION", "BANNER", "SUBTITLE", "badge", "color_enabled", "supports_unicode",
|
|
27
|
+
"print_banner", "print_phase", "print_step", "print_worker", "print_completion",
|
|
28
|
+
"print_warning", "print_error"]
|
|
29
|
+
|
|
30
|
+
VERSION = "2.0.0"
|
|
31
|
+
|
|
32
|
+
# Six letters, five rows, one space between glyphs: 46 columns at its widest.
|
|
33
|
+
BANNER = (
|
|
34
|
+
" _____ ___ __ __ _____ ____ ____ ",
|
|
35
|
+
"|_ _| |_ _| | \\/ | | ____| / ___| / ___|",
|
|
36
|
+
" | | | | | |\\/| | | _| | | \\___ \\",
|
|
37
|
+
" | | | | | | | | | |___ | |___ ___) |",
|
|
38
|
+
" |_| |___| |_| |_| |_____| \\____| |____/",
|
|
39
|
+
)
|
|
40
|
+
SUBTITLE = "timecs \u00b7 autonomous static & appsec analysis"
|
|
41
|
+
|
|
42
|
+
_RESET = "\033[0m"
|
|
43
|
+
_BADGES = {"INF": "\033[1;34m", "WRN": "\033[1;33m", "ERR": "\033[1;31m",
|
|
44
|
+
"AGT": "\033[1;35m", "SUC": "\033[1;32m"}
|
|
45
|
+
_RULE = "\u2500"
|
|
46
|
+
_ARROW = "\u2192"
|
|
47
|
+
_DOT = "\u00b7"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def color_enabled(stream: Any) -> bool:
|
|
51
|
+
"""Colour is for a human watching a terminal, not for a log file or a CI capture."""
|
|
52
|
+
if os.environ.get("NO_COLOR"):
|
|
53
|
+
return False
|
|
54
|
+
try:
|
|
55
|
+
return bool(stream.isatty())
|
|
56
|
+
except (AttributeError, ValueError):
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def _encodable(stream: Any, text: str) -> bool:
|
|
61
|
+
encoding = getattr(stream, "encoding", None)
|
|
62
|
+
if not encoding:
|
|
63
|
+
return False
|
|
64
|
+
try:
|
|
65
|
+
text.encode(encoding)
|
|
66
|
+
except (UnicodeEncodeError, LookupError):
|
|
67
|
+
return False
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def supports_unicode(stream: Any) -> bool:
|
|
72
|
+
"""True when this stream's own encoding can carry the rule and the arrow."""
|
|
73
|
+
return _encodable(stream, _RULE + _ARROW)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _glyphs(stream: Any) -> tuple:
|
|
77
|
+
"""The three non-ASCII characters this module can emit, each probed against the stream.
|
|
78
|
+
|
|
79
|
+
Probing exactly what is about to be written is what makes a UnicodeEncodeError unreachable:
|
|
80
|
+
a cp1252 console gets `-` and `->`, and a stream that cannot even carry the middle dot gets
|
|
81
|
+
an ASCII subtitle rather than an exception halfway through the banner.
|
|
82
|
+
"""
|
|
83
|
+
rule, arrow = (_RULE, _ARROW) if supports_unicode(stream) else ("-", "->")
|
|
84
|
+
dot = _DOT if _encodable(stream, _DOT) else "-"
|
|
85
|
+
return rule, arrow, dot
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def _write(line: str, stream: Any) -> None:
|
|
89
|
+
stream.write(line + "\n")
|
|
90
|
+
stream.flush()
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def badge(kind: str, message: str, stream: Any = sys.stderr) -> None:
|
|
94
|
+
"""One `[KIND] message` line. KIND is INF, WRN, ERR, AGT or SUC."""
|
|
95
|
+
tag = "[%s]" % kind
|
|
96
|
+
code = _BADGES.get(kind)
|
|
97
|
+
if code and color_enabled(stream):
|
|
98
|
+
tag = code + tag + _RESET
|
|
99
|
+
_write("%s %s" % (tag, message), stream)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def print_banner(target_path: Any, scope: str = "all", workers: int = 2,
|
|
103
|
+
version: str = VERSION, stream: Any = sys.stderr) -> None:
|
|
104
|
+
rule, arrow, dot = _glyphs(stream)
|
|
105
|
+
for line in BANNER:
|
|
106
|
+
_write(line, stream)
|
|
107
|
+
_write(SUBTITLE.replace(_DOT, dot), stream)
|
|
108
|
+
badge("INF", "TIMECS %s" % version, stream)
|
|
109
|
+
badge("INF", "target %s %s" % (arrow, target_path), stream)
|
|
110
|
+
badge("INF", "scope %s %s" % (arrow, scope), stream)
|
|
111
|
+
badge("INF", "workers %s %s" % (arrow, workers), stream)
|
|
112
|
+
_write(rule * 46, stream)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def print_phase(current: int, total: int, title: str, stream: Any = sys.stderr) -> None:
|
|
116
|
+
rule, _arrow, _dot = _glyphs(stream)
|
|
117
|
+
badge("AGT", "phase %d/%d %s %s" % (current, total, rule * 6, title), stream)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def print_step(step_num: int, title: str, details: str, stream: Any = sys.stderr) -> None:
|
|
121
|
+
_rule, arrow, _dot = _glyphs(stream)
|
|
122
|
+
badge("SUC", "step %d %s %s: %s" % (step_num, arrow, title, details), stream)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def print_worker(worker_id: Any, status: str, stream: Any = sys.stderr) -> None:
|
|
126
|
+
_rule, arrow, _dot = _glyphs(stream)
|
|
127
|
+
badge("AGT", "worker %s %s %s" % (worker_id, arrow, status), stream)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def print_completion(duration_s: float, total_findings: int, sarif_path: Optional[str] = None,
|
|
131
|
+
sbom_path: Optional[str] = None, stream: Any = sys.stderr) -> None:
|
|
132
|
+
_rule, arrow, _dot = _glyphs(stream)
|
|
133
|
+
badge("SUC", "scan complete %s %d finding(s) in %.2fs" % (arrow, total_findings, duration_s),
|
|
134
|
+
stream)
|
|
135
|
+
if sarif_path:
|
|
136
|
+
badge("INF", "sarif %s %s" % (arrow, sarif_path), stream)
|
|
137
|
+
if sbom_path:
|
|
138
|
+
badge("INF", "sbom %s %s" % (arrow, sbom_path), stream)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def print_warning(message: str, stream: Any = sys.stderr) -> None:
|
|
142
|
+
badge("WRN", message, stream)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def print_error(message: str, stream: Any = sys.stderr) -> None:
|
|
146
|
+
badge("ERR", message, stream)
|