Skip to content
sinopia0Public

About

p o i s o n -- A I -- d a t a s e t

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

Sinopia AST Rewriter

A small Rust research tool for simulating source-code poisonings in AI-assisted code generation (AI poisoning domain), by rewriting Rust source files through AST mutations.

Features

  • rename functions by prefixing with rewritten_
  • poison names with the following attacker tactics:
    • misleading naming (validate_backdoor_*, encrypt_noop_*)
    • polarity flips (is_/has_/should_ inverts semantics)
    • hidden triggers (*_trigger_42, *_BACKDOOR)
    • overfit prefix inversion (safe_* vs unsafe_*)
    • alias poisoning (dangerous=eval, safe map)
    • entropy/noise names (func_XYZ_noise123)
    • semantic collisions (process -> process_collide)
    • distribution poisoning (sanitize -> vuln_*, raw -> safe_*)
  • inject Markov-generated comments into function bodies and call sites
  • swap call arguments for any call with two or more arguments
  • rewrite existing // comments using text from Markov training
  • process single file or recursively scan a directory of *.rs files
  • training from *.txt files in a directory (eg. rfc-archive), caching via JSON
  • token limit fixed to 4000 for training to keep initial runs quick

Usage

# Compile and run on one file, no Markov training:
cargo run -- path/to/target.rs

# Run on a directory recursively, with text corpus from rfc-archive:
cargo run -- path/to/rust-project path/to/rfc-archive

The tool rewrites files in place and prints Rewrote: ... for each file.

Notes

  • Markov training will throttle to first 4000 tokens from the text corpus.
  • The generated code is formatted via prettyplease.
  • Existing comments are replaced to appear as generated and random.

About

p o i s o n -- A I -- d a t a s e t

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages