sourcecode 4.10.1__py3-none-any.whl → 4.10.3__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.
Potentially problematic release.
This version of sourcecode might be problematic. Click here for more details.
- sourcecode/__init__.py +1 -1
- sourcecode/runs.py +12 -1
- sourcecode/security_config_scan.py +38 -10
- sourcecode/spring_security_audit.py +2 -1
- {sourcecode-4.10.1.dist-info → sourcecode-4.10.3.dist-info}/METADATA +11 -4
- {sourcecode-4.10.1.dist-info → sourcecode-4.10.3.dist-info}/RECORD +9 -9
- {sourcecode-4.10.1.dist-info → sourcecode-4.10.3.dist-info}/WHEEL +0 -0
- {sourcecode-4.10.1.dist-info → sourcecode-4.10.3.dist-info}/entry_points.txt +0 -0
- {sourcecode-4.10.1.dist-info → sourcecode-4.10.3.dist-info}/licenses/LICENSE +0 -0
sourcecode/__init__.py
CHANGED
sourcecode/runs.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
+
import hashlib
|
|
5
6
|
import os
|
|
6
7
|
import time
|
|
7
8
|
import uuid
|
|
@@ -18,7 +19,17 @@ def _now() -> float:
|
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def _runs_dir(root: Path) -> Path:
|
|
21
|
-
|
|
22
|
+
override = os.environ.get("ASK_RUNS_DIR", "").strip()
|
|
23
|
+
if override:
|
|
24
|
+
return Path(override).expanduser().resolve()
|
|
25
|
+
if os.environ.get("ASK_RUNS_IN_REPO", "").lower() in ("1", "true", "yes", "on"):
|
|
26
|
+
return Path(root).resolve() / ".ask" / "runs"
|
|
27
|
+
try:
|
|
28
|
+
key_source = str(Path(root).resolve())
|
|
29
|
+
except Exception:
|
|
30
|
+
key_source = str(Path(root).absolute())
|
|
31
|
+
repo_key = hashlib.sha256(key_source.encode("utf-8", errors="replace")).hexdigest()[:16]
|
|
32
|
+
return Path.home() / ".sourcecode" / "runs" / repo_key
|
|
22
33
|
|
|
23
34
|
|
|
24
35
|
@dataclass
|
|
@@ -111,8 +111,8 @@ _IS_REFERENCE = re.compile(r"[$@]\{[^}]+\}|^\s*$|^\s*ENC\(|^\s*\*+\s*$")
|
|
|
111
111
|
#: XML elements whose text is a configured VALUE. Servlet/JEE spec vocabulary.
|
|
112
112
|
_DESCRIPTOR_VALUE = re.compile(
|
|
113
113
|
r"<(?P<tag>param-value|env-entry-value|value|property|password)\b[^>]*>"
|
|
114
|
-
r"(?P<value
|
|
115
|
-
re.IGNORECASE,
|
|
114
|
+
r"(?P<value>.*?)</(?P=tag)>",
|
|
115
|
+
re.IGNORECASE | re.DOTALL,
|
|
116
116
|
)
|
|
117
117
|
|
|
118
118
|
_DESCRIPTOR_INIT_PARAM = re.compile(
|
|
@@ -124,8 +124,8 @@ _DESCRIPTOR_PARAM_NAME = re.compile(
|
|
|
124
124
|
re.IGNORECASE,
|
|
125
125
|
)
|
|
126
126
|
_DESCRIPTOR_PARAM_VALUE = re.compile(
|
|
127
|
-
r"<param-value\b[^>]*>(?P<value
|
|
128
|
-
re.IGNORECASE,
|
|
127
|
+
r"<param-value\b[^>]*>(?P<value>.*?)</param-value>",
|
|
128
|
+
re.IGNORECASE | re.DOTALL,
|
|
129
129
|
)
|
|
130
130
|
_JAVAMELODY_CREDENTIAL_PARAMS: frozenset[str] = frozenset({
|
|
131
131
|
"authorized-users",
|
|
@@ -212,6 +212,15 @@ _COMMENTED_CONFIG_CONTROLS: tuple[tuple[re.Pattern, str, str], ...] = (
|
|
|
212
212
|
),
|
|
213
213
|
)
|
|
214
214
|
|
|
215
|
+
_COMMENTED_JAVA_HINTS = (
|
|
216
|
+
"@PreAuthorize", "@PostAuthorize", "@Secured", "@RolesAllowed", "@DenyAll",
|
|
217
|
+
"@PermitAll", "FiltroSeguridad", "Security", "Authz", "Authorize",
|
|
218
|
+
"Authorized", "setSecure", "csrfTokenRepository", "csrf(",
|
|
219
|
+
)
|
|
220
|
+
_COMMENTED_XML_HINTS = (
|
|
221
|
+
"<transport-guarantee", "CONFIDENTIAL", "<security-constraint", "<intercept-url",
|
|
222
|
+
)
|
|
223
|
+
|
|
215
224
|
|
|
216
225
|
@dataclass(frozen=True)
|
|
217
226
|
class SecurityConfigObservation:
|
|
@@ -355,7 +364,14 @@ def _scan_descriptor(text: str, rel: str) -> "list[SecurityConfigObservation]":
|
|
|
355
364
|
holds a reference and is not reported; one that carries a digest literal
|
|
356
365
|
holds the credential itself, in a file under version control.
|
|
357
366
|
"""
|
|
367
|
+
def _xml_value(raw: str) -> str:
|
|
368
|
+
value = raw.strip()
|
|
369
|
+
if value.startswith("<![CDATA[") and value.endswith("]]>"):
|
|
370
|
+
value = value[len("<![CDATA["):-len("]]>")]
|
|
371
|
+
return value.strip()
|
|
372
|
+
|
|
358
373
|
out: "list[SecurityConfigObservation]" = []
|
|
374
|
+
javamelody_value_offsets: set[int] = set()
|
|
359
375
|
for param in _DESCRIPTOR_INIT_PARAM.finditer(text):
|
|
360
376
|
body = param.group("body")
|
|
361
377
|
name_m = _DESCRIPTOR_PARAM_NAME.search(body)
|
|
@@ -363,22 +379,29 @@ def _scan_descriptor(text: str, rel: str) -> "list[SecurityConfigObservation]":
|
|
|
363
379
|
if name_m is None or value_m is None:
|
|
364
380
|
continue
|
|
365
381
|
name = name_m.group("value").strip().lower()
|
|
366
|
-
value = value_m.group("value")
|
|
382
|
+
value = _xml_value(value_m.group("value"))
|
|
367
383
|
if name not in _JAVAMELODY_CREDENTIAL_PARAMS:
|
|
368
384
|
continue
|
|
369
385
|
if not value or _IS_REFERENCE.search(value):
|
|
370
386
|
continue
|
|
371
387
|
if ":" not in value:
|
|
372
388
|
continue
|
|
373
|
-
if _DIGEST_LITERAL.search(value):
|
|
374
|
-
continue
|
|
375
389
|
user = value.split(":", 1)[0].strip() or "user"
|
|
390
|
+
value_offset = param.start("body") + value_m.start("value")
|
|
391
|
+
javamelody_value_offsets.add(value_offset)
|
|
392
|
+
digest = _DIGEST_LITERAL.search(value)
|
|
393
|
+
evidence = (
|
|
394
|
+
f"<param-value>{user}:…{{{digest.group('algo')}}}"
|
|
395
|
+
f"{digest.group('digest')[:8]}…</param-value>"
|
|
396
|
+
if digest is not None
|
|
397
|
+
else f"<param-value>{user}:…</param-value>"
|
|
398
|
+
)
|
|
376
399
|
out.append(SecurityConfigObservation(
|
|
377
400
|
rule="SEC-007",
|
|
378
401
|
file=rel,
|
|
379
|
-
line=_line_of(text,
|
|
402
|
+
line=_line_of(text, value_offset),
|
|
380
403
|
symbol=rel,
|
|
381
|
-
evidence=
|
|
404
|
+
evidence=evidence,
|
|
382
405
|
detail=(
|
|
383
406
|
"JavaMelody authorized-users stores a monitoring-console credential "
|
|
384
407
|
"directly in the deployment descriptor. The value is redacted here; "
|
|
@@ -386,7 +409,9 @@ def _scan_descriptor(text: str, rel: str) -> "list[SecurityConfigObservation]":
|
|
|
386
409
|
),
|
|
387
410
|
))
|
|
388
411
|
for match in _DESCRIPTOR_VALUE.finditer(text):
|
|
389
|
-
|
|
412
|
+
if match.start("value") in javamelody_value_offsets:
|
|
413
|
+
continue
|
|
414
|
+
value = _xml_value(match.group("value"))
|
|
390
415
|
if not value or _IS_REFERENCE.search(value):
|
|
391
416
|
continue
|
|
392
417
|
digest = _DIGEST_LITERAL.search(value)
|
|
@@ -456,6 +481,9 @@ def _scan_commented_controls(
|
|
|
456
481
|
from sourcecode.source_text import commented_spans
|
|
457
482
|
|
|
458
483
|
rules = _COMMENTED_XML_CONTROLS if xml else _COMMENTED_JAVA_CONTROLS
|
|
484
|
+
hints = _COMMENTED_XML_HINTS if xml else _COMMENTED_JAVA_HINTS
|
|
485
|
+
if not any(hint in source for hint in hints):
|
|
486
|
+
return []
|
|
459
487
|
out: "list[SecurityConfigObservation]" = []
|
|
460
488
|
seen: set[tuple[str, int]] = set()
|
|
461
489
|
for start, end in commented_spans(source, xml=xml):
|
|
@@ -508,7 +508,8 @@ def _line_of(source: str, offset: int) -> int:
|
|
|
508
508
|
_JAVA_METHOD_RE = re.compile(
|
|
509
509
|
r"(?P<mods>(?:(?:public|protected|private|static|final|synchronized|abstract|native)\s+)*)"
|
|
510
510
|
r"(?P<ret>[\w.$<>\[\], ?]+)\s+"
|
|
511
|
-
r"(?P<name>
|
|
511
|
+
r"(?P<name>(?!(?:if|for|while|switch|catch|synchronized|return|new|throw|try|else|do)\b)"
|
|
512
|
+
r"[a-zA-Z_][\w$]*)\s*\([^;{}]*\)\s*(?:throws\s+[^{]+)?\{",
|
|
512
513
|
re.MULTILINE,
|
|
513
514
|
)
|
|
514
515
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sourcecode
|
|
3
|
-
Version: 4.10.
|
|
3
|
+
Version: 4.10.3
|
|
4
4
|
Summary: Persistent structural context and ultra-fast repeated analysis for AI coding agents
|
|
5
5
|
License-File: LICENSE
|
|
6
6
|
Keywords: agents,ai,codebase,context,developer-tools,llm
|
|
@@ -42,7 +42,7 @@ Description-Content-Type: text/markdown
|
|
|
42
42
|
|
|
43
43
|
**Context · Impact · Migration · Architecture · Review — everything from one structural model.**
|
|
44
44
|
|
|
45
|
-

|
|
46
46
|

|
|
47
47
|
|
|
48
48
|
> **ASK Engine** is the product. The CLI command is **`ask`**. The legacy **`sourcecode`**
|
|
@@ -73,7 +73,14 @@ These numbers are cache-layer benchmarks, not a promise for every command. Per-s
|
|
|
73
73
|
|
|
74
74
|
With the right command class, ASK Engine becomes **constant infrastructure** inside agent loops — call the fast/context surfaces before edits and reserve deep compositions for the points where their evidence is worth the runtime.
|
|
75
75
|
|
|
76
|
-
**Large-repo controls.** Set `ASK_PROGRESS=1` to get line heartbeats in non-TTY
|
|
76
|
+
**Large-repo controls.** Set `ASK_PROGRESS=1` to get line heartbeats in non-TTY
|
|
77
|
+
supervised runs. Long repo-wide/deep runs also write durable records under
|
|
78
|
+
`~/.sourcecode/runs/<repo-hash>/` by default, not inside the audited repository;
|
|
79
|
+
set `ASK_RUNS_IN_REPO=1` only when repo-local `.ask/runs` records are intentional.
|
|
80
|
+
Set `ASK_MAX_ANALYSIS_SECONDS=<seconds>` to fail before starting a repo-wide/deep
|
|
81
|
+
command whose configured budget is below its safe floor. Use
|
|
82
|
+
`ask audit-report --from-risk risk.json` to package an existing risk run instead
|
|
83
|
+
of recomputing it.
|
|
77
84
|
|
|
78
85
|
**What a warm actually covers.** `ask cache warm` runs the compact analysis: it rebuilds the
|
|
79
86
|
shared structural layers (L1/L2 + the Repository Intelligence Snapshot + the shared Canonical
|
|
@@ -99,7 +106,7 @@ brew tap haroundominique/sourcecode && brew install sourcecode
|
|
|
99
106
|
# pip / pipx
|
|
100
107
|
pipx install sourcecode # or: pip install sourcecode
|
|
101
108
|
|
|
102
|
-
ask version # ask 4.10.
|
|
109
|
+
ask version # ask 4.10.3 — and, on a build that has aged,
|
|
103
110
|
# how many releases have probably shipped since
|
|
104
111
|
```
|
|
105
112
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
sourcecode/__init__.py,sha256=
|
|
1
|
+
sourcecode/__init__.py,sha256=kRwEKt8ufgmTyXFYrYP-5dM5o3eTQYMoUFRLOvoQ0as,309
|
|
2
2
|
sourcecode/adaptive_scanner.py,sha256=yJBKjNpkY6bpueYJ2YnRezen3sYZDecEt7WaaNWdqug,9466
|
|
3
3
|
sourcecode/archetype.py,sha256=CZvRLpkHot_D8D3JFQVorr-EHDJyh0BbS7RnSTqBigM,40499
|
|
4
4
|
sourcecode/architectural_baseline.py,sha256=agDSwGEakdkgLLh5xnd3hiD_TC6pRujWt4klnuYF1wo,18689
|
|
@@ -97,13 +97,13 @@ sourcecode/repository_ir.py,sha256=UdA13zDUvhgZvdUt8BIbfHOXi40OkdvqtpMJG7hYkms,3
|
|
|
97
97
|
sourcecode/ris.py,sha256=SjjDNMcc9Zr9us9G8ikBVkoPXKK3BpM-dBodSGMh_g4,24783
|
|
98
98
|
sourcecode/risk.py,sha256=UgTVdMc8XBArO6D9e2Xx9I-kKqx-PW4W0hSe1Jy9qjU,54491
|
|
99
99
|
sourcecode/rule_catalog.py,sha256=xmphuULUCtg_GWTbriwY25D-N2IaeMXXvB5CNU1xSuA,4925
|
|
100
|
-
sourcecode/runs.py,sha256=
|
|
100
|
+
sourcecode/runs.py,sha256=K1G7WjSLACZFNklRupFiHjmF5SJYtoo1OWjA0h8-q7Y,4761
|
|
101
101
|
sourcecode/runtime_classifier.py,sha256=uTAD6BDCiBLUZEDRfqk718kM4RTT_vAbfkcOI2_Xx58,18432
|
|
102
102
|
sourcecode/sarif.py,sha256=3hQEegUxIZbojFdY59oB-yKsK-rnafHdTNmYsEP2--A,25984
|
|
103
103
|
sourcecode/scanner.py,sha256=z3CV0rcGunu0Y8mpNgp07wI7nxT0pxw1BkXRRtI0Rpo,9609
|
|
104
104
|
sourcecode/schema.py,sha256=aHNXDf8LGyUC8ZDE_VS9kiskC2-Oswhi_WnpdGy6HDw,24897
|
|
105
105
|
sourcecode/security_config.py,sha256=KblMEoRiEjrIE68YsPaUAFebxFp8UM7MS7lAk5CGD8U,3531
|
|
106
|
-
sourcecode/security_config_scan.py,sha256=
|
|
106
|
+
sourcecode/security_config_scan.py,sha256=RDxBNm7oVdAaY6gbQgeA2FjHy2pVc6MPRnrBwTnASqY,27247
|
|
107
107
|
sourcecode/security_posture.py,sha256=CjJ2Qm87HhKXepnaWx1ncJLW-SxI18udCmUDIkCyAsY,50270
|
|
108
108
|
sourcecode/semantic_analyzer.py,sha256=bpgdC6m0_ftVtRf3rSdwhbhWjnZnGxRXaZVcfe4BbcQ,95414
|
|
109
109
|
sourcecode/semantic_impact_engine.py,sha256=t09IirGC3JjQDy33JZd1_WKzQVKXkoNl3-XEUr5kjis,20563
|
|
@@ -118,7 +118,7 @@ sourcecode/spring_impact.py,sha256=keWoE1tN5B_SzJx9F-53RKEL0b2edhJdZMTfocmJZLY,8
|
|
|
118
118
|
sourcecode/spring_model.py,sha256=zOAgFmrRbG4a6KLm1TJl55aWMyPNsz3OS3FSczqPG6A,16594
|
|
119
119
|
sourcecode/spring_profiles.py,sha256=-kwrCK0O-MRjrCp6SA1d31t--o4Tg87iqPVrTwxoIUs,19605
|
|
120
120
|
sourcecode/spring_properties.py,sha256=kPTk5qAJxdbHc1hclhHAP0O-hCIzBn8PTh3lzl-I4a4,8400
|
|
121
|
-
sourcecode/spring_security_audit.py,sha256=
|
|
121
|
+
sourcecode/spring_security_audit.py,sha256=KkhIx1WhAD9ccw3P-CcHP3d8p0OAOivKT5CrX2Zuq8k,46257
|
|
122
122
|
sourcecode/spring_semantic.py,sha256=UrmLg_4gmBVmMqvSnUMgSReVEERVGv3X7LYDBEs6k_o,16598
|
|
123
123
|
sourcecode/spring_tx_analyzer.py,sha256=_wqjRktqdPS6PiXXxtTkCD1t6BaE2uhqx6ioYY-ULAw,44153
|
|
124
124
|
sourcecode/summarizer.py,sha256=0aD4x3vgPngqBCEBKGuES1J2Vk5f7mqCm_ZWErwm3js,27025
|
|
@@ -193,8 +193,8 @@ sourcecode/telemetry/consent.py,sha256=pQdl-QeLl6Gcibn0eWHSKZrm-HYSsjpVqOnjrgFp8
|
|
|
193
193
|
sourcecode/telemetry/events.py,sha256=4_yeO58U-Cwc1Qb27VB0_EjhmroY0k91n3_VGxeALB8,2776
|
|
194
194
|
sourcecode/telemetry/filters.py,sha256=RzxauTz8HliO4BllQnXEXc7zTeqdCZi5MgqGEDuW7OQ,6570
|
|
195
195
|
sourcecode/telemetry/transport.py,sha256=4gGHsq0WeY9VywEZXA3vUxykfiYnw9uuqfjAAec7F8o,1681
|
|
196
|
-
sourcecode-4.10.
|
|
197
|
-
sourcecode-4.10.
|
|
198
|
-
sourcecode-4.10.
|
|
199
|
-
sourcecode-4.10.
|
|
200
|
-
sourcecode-4.10.
|
|
196
|
+
sourcecode-4.10.3.dist-info/METADATA,sha256=6_uj0P5A9uKdHBcaXMZQic-g9lTXCknIu4m9X9sYj1g,36657
|
|
197
|
+
sourcecode-4.10.3.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
198
|
+
sourcecode-4.10.3.dist-info/entry_points.txt,sha256=-JEAdChrK5We51kZcb7OaDcyil-dHBjBPL-NhuO-QY8,89
|
|
199
|
+
sourcecode-4.10.3.dist-info/licenses/LICENSE,sha256=7DdHrU9Z_3e7dSvq4ISijZNjnuHo5NIHNiHDouMQ9JU,10491
|
|
200
|
+
sourcecode-4.10.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|