T09 · Insecure Skill Coding Practices
- Location
`. 3. The formatter processes all content as ordinary Markdown, including protected contexts such as fenced and inline code. 4. The global transformations change semantically meaningful content. 5. `Path.write_text()` overwrites the original file without presenting a diff, preserving a backup, or requesting confirmation. 6. The corrupted commands, code, or configuration may subsequently be copied, executed, published, or consumed by another system. ### Impact Assessment This issue does not provide privile ...[truncated 740 chars]:11- Finding
Context-Insensitive In-Place Rewriting Can Corrupt User-Controlled Files
- Content
View full analysis
0: result.append(f"\n{line}\n" if i < len(lines) - 1 else line) continue if line.startswith("#"): level = len(line) - len(line.lstrip("#")) if level > current_level + 1: line = "#" * (current_level + 1) + line[level:] current_level = level result.append(line) return "\n".join(result) def fix_emphasis(text): """Prefer **bold** over __bold__, *italic* over _italic_.""" text = re.sub(r"\*\*(.+?)\*\*", r"**\1**", text) # already atx bold text = re.sub(r"__(.+?)__", r"**\1**", text) text = re.sub(r"_(.+?)_", r"*\1*", text) return text ``` ```python path = Path(sys.argv[1]) if not path.exists(): print(f"Error: {path} not found") sys.exit(1) text = path.read_text(encoding="utf-8") original = text text = fix_emphasis(text) text = fix_headings(text) text = fix_trailing_whitespace(text) text = fix_blank_lines(text) if text != original: path.write_ ...[truncated 2721 chars]- Remediation
View remediation
