Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0239f80
fix(analyzer): stabilize TM1 window identity
chrisknvidia Sep 23, 2026
193bb90
Merge main into fix/christopherk/tm1-window-identity
chrisknvidia Sep 23, 2026
7fee7af
Merge remote-tracking branch 'origin/main' into fix/christopherk/tm1-…
chrisknvidia Sep 28, 2026
912263f
Merge remote-tracking branch 'origin/main' into fix/christopherk/tm1-…
chrisknvidia Sep 28, 2026
68e22d0
fix(analyzer): track eager receiver side effects
chrisknvidia Sep 28, 2026
2eefaa0
fix(analyzer): preserve lexical TM1 when dataflow abstains
chrisknvidia Oct 5, 2026
60a88ce
fix(analyzer): require a retained companion owner
chrisknvidia Oct 5, 2026
24924e8
fix(analyzer): preserve execution scope in binding evidence
chrisknvidia Oct 5, 2026
e3c3bfd
style(analyzer): simplify binding event deduplication
chrisknvidia Oct 5, 2026
ebc69d7
fix: preserve runtime and retained shell evidence
chrisknvidia Oct 5, 2026
03e862e
fix(analyzer): preserve called-slot identity and cached method evidence
chrisknvidia Oct 5, 2026
637c2fb
fix: preserve cached subprocess slot state across scoped imports
chrisknvidia Oct 5, 2026
cf7805f
fix(analyzer): reconcile explicit cached-slot evidence across scopes
chrisknvidia Oct 5, 2026
0fb9acd
Integrate current main with reviewed Python analyzer changes
chrisknvidia Oct 5, 2026
2433033
fix: abstain from cached slot proof after eager effects
chrisknvidia Oct 5, 2026
d8cef86
test: retain lexical findings after unknown cached-slot effects
chrisknvidia Oct 5, 2026
53ac4d1
fix: bound direct called-slot evidence to known execution order
chrisknvidia Oct 5, 2026
4ed5340
fix: limit direct slot proof to single assignment targets
chrisknvidia Oct 5, 2026
46dd4ca
fix: invalidate slot evidence on protocols and unsafe releases
chrisknvidia Oct 5, 2026
d6f7de3
fix: keep legacy shadow proof isolated from later effects
chrisknvidia Oct 5, 2026
b175297
fix: abstain from cached replacement proof after unknown effects
chrisknvidia Oct 5, 2026
f2d34c8
fix: retain native callable detection across cached slot stores
chrisknvidia Oct 5, 2026
5e51caa
fix: retain shell findings for native receiver assignments
chrisknvidia Oct 5, 2026
481a8fb
fix: preserve native Popen replacement warnings
chrisknvidia Oct 5, 2026
9162964
Merge current main into fix/christopherk/tm1-window-identity
rng1995 Oct 8, 2026
15b4e58
fix(analyzer): require proven replacement before revoking lexical TM1
rng1995 Oct 8, 2026
548b17c
test: account for TM1 Python parsing in marker ownership ledger
rng1995 Oct 8, 2026
7b643ff
fix(analyzer): keep one TM1 owner for true-prefixed names without AST…
rng1995 Oct 8, 2026
327591b
fix(analyzer): report each true-prefixed shell call that #577 reports
rng1995 Oct 8, 2026
4031711
Merge current main (with #577) into fix/christopherk/tm1-window-identity
rng1995 Oct 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 105 additions & 16 deletions src/skillspector/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class SecurityTextView:
text: str
source_offsets: array[int] | None = None
reconstructions: tuple[SecurityTextReconstruction, ...] = ()
right_boundary_is_fixed: bool = False
right_boundary_recovery_start: int | None = None

def source_offset(self, derived_offset: int) -> int:
"""Map a derived character offset to the corresponding source offset."""
Expand Down Expand Up @@ -1679,6 +1681,30 @@ def _contextual_default_ignorable_spans(
yield span_start, end


def _normalization_ignored_spans_in_gap(
text: str,
gap_start: int,
gap_end: int,
) -> Iterator[tuple[int, int]]:
"""Yield the normalized-view removals inside one contextual gap."""
for match in _DEFAULT_IGNORABLE_RUN_PATTERN.finditer(text, gap_start, gap_end):
start, end = match.span()
ignored_start = (
start
if _is_unconditionally_ignored(text[start])
or _is_contextual_default_ignorable_offset(text, start)
else start + 1
)
ignored_end = (
end
if _is_unconditionally_ignored(text[end - 1])
or _is_contextual_default_ignorable_offset(text, end - 1)
else end - 1
)
if ignored_start < ignored_end:
yield ignored_start, ignored_end


def _normalization_ignored_spans(
text: str,
check_runtime: Callable[[], None] | None = None,
Expand All @@ -1689,22 +1715,7 @@ def _normalization_ignored_spans(
require_word_boundaries=False,
check_runtime=check_runtime,
):
for match in _DEFAULT_IGNORABLE_RUN_PATTERN.finditer(text, gap_start, gap_end):
start, end = match.span()
ignored_start = (
start
if _is_unconditionally_ignored(text[start])
or _is_contextual_default_ignorable_offset(text, start)
else start + 1
)
ignored_end = (
end
if _is_unconditionally_ignored(text[end - 1])
or _is_contextual_default_ignorable_offset(text, end - 1)
else end - 1
)
if ignored_start < ignored_end:
yield ignored_start, ignored_end
yield from _normalization_ignored_spans_in_gap(text, gap_start, gap_end)


def _contextual_default_ignorable_offsets(
Expand Down Expand Up @@ -1813,6 +1824,55 @@ def normalized_security_view(
return SecurityTextView("normalized", output.getvalue(), offsets)


def normalized_security_prefix(text: str, max_chars: int) -> str:
"""Return an exact bounded prefix of the normalized security projection."""
if max_chars <= 0:
return ""

output = StringIO()
output_chars = 0

def append(character: str) -> bool:
nonlocal output_chars
normalized = unicodedata.normalize("NFKC", character).translate(ASCII_CONFUSABLE_SKELETON)
remaining = max_chars - output_chars
output.write(normalized[:remaining])
output_chars += min(len(normalized), remaining)
return output_chars >= max_chars

source_offset = 0
while source_offset < len(text) and output_chars < max_chars:
if not _is_token_gap_character(text[source_offset]):
if append(text[source_offset]):
break
source_offset += 1
continue

gap_start = source_offset
while source_offset < len(text) and _is_token_gap_character(text[source_offset]):
source_offset += 1
gap_end = source_offset
before_is_word = gap_start > 0 and _is_word_character(text[gap_start - 1])
after_is_word = gap_end < len(text) and _is_word_character(text[gap_end])
ignored_spans = iter(
_normalization_ignored_spans_in_gap(text, gap_start, gap_end)
if before_is_word or after_is_word
else ()
)
next_ignored = next(ignored_spans, None)
gap_offset = gap_start
while gap_offset < gap_end and output_chars < max_chars:
if next_ignored is not None and gap_offset == next_ignored[0]:
gap_offset = next_ignored[1]
next_ignored = next(ignored_spans, None)
continue
if not _is_unconditionally_ignored(text[gap_offset]) and append(text[gap_offset]):
break
gap_offset += 1

return output.getvalue()


def obfuscated_instruction_view(
text: str,
check_runtime: Callable[[], None] | None = None,
Expand Down Expand Up @@ -2171,6 +2231,35 @@ def _requires_normalized_security_view_uncached(
return not text.translate(_REMOVE_ALLOWED_FORMAT_CHARACTERS).isprintable()


def _has_derived_security_view(text: str) -> bool:
"""Return whether security projection produces a distinct text view."""
if text.isascii():
return (
_IGNORED_ASCII_CONTROL.search(text) is not None
or _has_letter_spacing_run(text)
or next(_obfuscated_instruction_matches(text), None) is not None
)
if any(
unicodedata.normalize("NFKC", character).translate(ASCII_CONFUSABLE_SKELETON) != character
for character in text
):
return True
if any(_is_unconditionally_ignored(character) for character in text):
return True
if next(_normalization_ignored_spans(text), None) is not None:
return True
if "\ufffd" in text or next(_compact_gap_offsets(text), None) is not None:
return True
return (
_has_letter_spacing_run(text)
or next(
_obfuscated_instruction_matches(text),
None,
)
is not None
)


def security_text_views(
text: str,
check_runtime: Callable[[], None] | None = None,
Expand Down
Loading
Loading