Skip to content

Shell quoted expansions consume trailing comment padding in completeness checks #911

Closed

Description

@mbakman

Reproduction

On the published v2.13.1 scanner and main at d7338f5, these complete shell lines become static_parse_limit when followed by an inert 6,000-character comment:

from skillspector.nodes.analyzers.static_patterns_tool_misuse import has_bounded_parse_exhaustion

padding = "\n# " + "." * 6000 + "\n"
for source in (
    'echo "hello $(printf x) ${DELAY}s"\n',
    'mkdir -p "$(dirname "$STORE")" || fail "cannot create $(dirname "$STORE")"\n',
):
    print(has_bounded_parse_exhaustion(source + padding, lambda: None, file_type="shell"))

Both return True; the snippets are syntactically valid shell and the appended comment changes no behavior. Nested command substitutions still need independent security inspection, but a closing quote in a data argument must not open a new word extending through later source.

Expected behavior and proposed scope

Complete inspection of these inputs without increasing parser budgets or suppressing incomplete-analysis findings. This is related to #628 and #694. The proposed boundary shortcut in closed #780 is not safe to reuse: its review identified comment, heredoc and single-quote counterexamples that must remain covered.

I am investigating a conservative refinement using lexical ownership established from the start of shell source, retaining the existing conservative path whenever ownership cannot be proven. The change must preserve nested commands, runtime-selected destructive operands, malformed/over-budget inputs, and the #780 review controls. Other host languages and prose remain outside this focused change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions