Skip to content

Commit ba04bd4

Browse files
unclesp1d3rCopilot
andauthored
Add code review automation and Rust standards documentation with IPv4/IPv6 detection (#119)
* feat(hooks): add Code Simplicity Checker for automated code review - Introduced a new hook that triggers a comprehensive code review upon agent completion, focusing on simplifying code, reducing test bloat, and ensuring idiomatic style. - The hook includes detailed analysis steps and simplification principles to guide the refactoring process, enhancing code maintainability and readability. This addition aims to streamline the code review process and promote best practices in code simplicity. Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io> * feat(steering): add comprehensive documentation for Rust standards, error handling, performance optimization, and configuration management - Introduced multiple markdown files detailing standards and best practices for Rust development within the Stringy project. - Added guidelines for Cargo.toml configuration, error handling patterns using `thiserror`, performance optimization techniques, and strict coding standards. - Included examples and code snippets to illustrate best practices for string extraction, error handling, and performance benchmarks. - Enhanced documentation aims to improve code quality, maintainability, and performance across the project. This addition significantly enriches the project's documentation, providing clear guidance for developers and contributors. Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io> * feat(simplicity-review): add documentation for code simplicity review process - Introduced two new markdown files: `simplicity_review.md` and `simplicity-review.prompt.md`. - The `simplicity_review.md` outlines steps for reviewing code for simplicity. - The `simplicity-review.prompt.md` provides detailed analysis steps and simplification principles to guide developers in refactoring code effectively. - This addition aims to enhance code maintainability and promote best practices in code simplicity. Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io> * feat(classification): enhance semantic classifier with IPv4/IPv6 detection and documentation updates - Implemented detection for both IPv4 and IPv6 addresses within the `SemanticClassifier`, including support for port handling and bracketed notation. - Updated the classification logic to include comprehensive validation for IP addresses, reducing false positives through heuristic checks. - Enhanced documentation in `README.md` and `classification.md` to reflect new capabilities and provide usage examples for IP address classification. - Refactored the `semantic.rs` module to improve code clarity and maintainability, including detailed comments on the classification process. This enhancement significantly improves the library's ability to analyze network indicators, facilitating better binary analysis and string extraction. Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io> * Fix PR review feedback: port validation, test clarity, and remove version number heuristic (#120) * Initial plan * fix: address PR review comments - spelling, port validation, test comment, and documentation Co-authored-by: unclesp1d3r <251112+unclesp1d3r@users.noreply.github.com> * refactor: remove version number heuristic, accept all valid IPv4 addresses Co-authored-by: unclesp1d3r <251112+unclesp1d3r@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: unclesp1d3r <251112+unclesp1d3r@users.noreply.github.com> --------- Signed-off-by: UncleSp1d3r <unclesp1d3r@evilbitlabs.io> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
1 parent d1d2bfd commit ba04bd4

15 files changed

Lines changed: 1729 additions & 197 deletions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Follow the steps in the .github/prompt/simplicity-review.prompt.md file to review the code for simplicity.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
CODE SIMPLIFICATION REVIEW
2+
3+
Start by examining the uncommitted changes in the current codebase.
4+
5+
ANALYSIS STEPS:
6+
7+
1. Identify what files have been modified or added
8+
2. Review the actual code changes
9+
3. Apply simplification principles below
10+
4. Refactor directly, then show what you changed
11+
12+
SIMPLIFICATION PRINCIPLES:
13+
14+
Complexity Reduction:
15+
16+
- Remove abstraction layers that don't provide clear value
17+
- Replace complex patterns with straightforward implementations
18+
- Use language idioms over custom abstractions
19+
- If a simple function/lambda works, use it—don't create classes
20+
21+
Test Proportionality:
22+
23+
- Keep only tests for critical functionality and real edge cases
24+
- Delete tests for trivial operations, framework behavior, or hypothetical scenarios
25+
- For small projects: aim for \<10 meaningful tests per feature
26+
- Test code should be shorter than implementation
27+
28+
Idiomatic Code:
29+
30+
- Use conventional patterns for the language
31+
- Prioritize readability and maintainability
32+
- Apply the principle of least surprise
33+
34+
Ask yourself: "What's the simplest version that actually works reliably?"
35+
36+
Make the refactoring changes, then summarize what you simplified and why. Always finish by running `just ci-check` and ensuring that all checks and tests remain green.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"enabled": true,
3+
"name": "Code Simplicity Checker",
4+
"description": "When the agent finishes its work, automatically trigger a comprehensive code review to eliminate unnecessary complexity, refactor for simplicity, reduce test bloat, and verify idiomatic style before finalizing any code changes",
5+
"version": "1",
6+
"when": {
7+
"type": "agentStop"
8+
},
9+
"then": {
10+
"type": "askAgent",
11+
"prompt": "CODE SIMPLIFICATION REVIEW\n\nStart by examining the uncommitted changes in the current codebase.\n\nANALYSIS STEPS:\n1. Identify what files have been modified or added\n2. Review the actual code changes\n3. Apply simplification principles below\n4. Refactor directly, then show what you changed\n\nSIMPLIFICATION PRINCIPLES:\n\nComplexity Reduction:\n- Remove abstraction layers that don't provide clear value\n- Replace complex patterns with straightforward implementations\n- Use language idioms over custom abstractions\n- If a simple function/lambda works, use it—don't create classes\n\nTest Proportionality:\n- Keep only tests for critical functionality and real edge cases\n- Delete tests for trivial operations, framework behavior, or hypothetical scenarios\n- For small projects: aim for <10 meaningful tests per feature\n- Test code should be shorter than implementation\n\nIdiomatic Code:\n- Use conventional patterns for the language\n- Prioritize readability and maintainability\n- Apply the principle of least surprise\n\nAsk yourself: \"What's the simplest version that actually works reliably?\"\n\nMake the refactoring changes, then summarize what you simplified and why. Always finish by running `just ci-check` and ensuring that all checks and tests remain green."
12+
}
13+
}

‎.kiro/steering/rust/cargo-toml.md‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
inclusion: fileMatch
3+
fileMatchPattern: [Cargo.toml]
4+
---
5+
6+
# Cargo.toml Standards for Stringy
7+
8+
## Package Configuration
9+
10+
- Use **Rust 2024 Edition** (MSRV: 1.91+) as specified in the package
11+
- Single crate structure (not a workspace)
12+
- Enforce lint policy via `[lints.rust]` configuration
13+
- Forbid unsafe code globally
14+
- Deny all warnings to preserve code quality
15+
16+
Example `Cargo.toml` structure:
17+
18+
```toml
19+
[package]
20+
name = "stringy"
21+
version = "0.1.0"
22+
edition = "2024"
23+
authors = ["UncleSp1d3r <unclesp1d3r@evilbitlabs.io>"]
24+
description = "A smarter alternative to the strings command that leverages format-specific knowledge"
25+
license = "Apache-2.0"
26+
repository = "https://github.com/EvilBit-Labs/StringyMcStringFace"
27+
homepage = "http://evilbitlabs.io/StringyMcStringFace/"
28+
keywords = ["binary", "strings", "analysis", "reverse-engineering", "malware"]
29+
categories = ["command-line-utilities", "development-tools"]
30+
31+
[lib]
32+
name = "stringy"
33+
path = "src/lib.rs"
34+
35+
[[bin]]
36+
name = "stringy"
37+
path = "src/main.rs"
38+
39+
[lints.rust]
40+
unsafe_code = "forbid"
41+
warnings = "deny"
42+
```
43+
44+
## Dependencies
45+
46+
- **Core dependencies**:
47+
48+
- `clap = { version = "4.5", features = ["derive"] }` - CLI argument parsing
49+
- `goblin = "0.10"` - Binary format parsing (ELF, PE, Mach-O)
50+
- `serde = { version = "1.0", features = ["derive"] }` - Serialization
51+
- `serde_json = "1.0"` - JSON output
52+
- `thiserror = "2.0"` - Structured error types
53+
54+
- **Dev dependencies**:
55+
56+
- `criterion = "0.7"` - Benchmarking
57+
- `insta = "1.0"` - Snapshot testing
58+
- `tempfile = "3.8"` - Temporary file handling in tests
59+
60+
## Build Profiles
61+
62+
- Use `[profile.dist]` for distribution builds with LTO:
63+
64+
```toml
65+
[profile.dist]
66+
inherits = "release"
67+
lto = "thin"
68+
```
69+
70+
## Benchmarks
71+
72+
- Define benchmarks in `[[bench]]` sections:
73+
74+
```toml
75+
[[bench]]
76+
name = "elf"
77+
harness = false
78+
```
79+
80+
## Package Metadata
81+
82+
- Include proper license (Apache-2.0)
83+
- Provide clear description for binary analysis tool
84+
- Include relevant keywords for discoverability
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
inclusion: fileMatch
3+
fileMatchPattern: ['**/config*.rs', '**/*config*.rs']
4+
---
5+
6+
# Configuration Management Standards for Stringy
7+
8+
## Configuration Architecture
9+
10+
Stringy uses **CLI arguments only** for configuration via `clap`:
11+
12+
- **Command-line flags** (only source of configuration)
13+
- **No configuration files** - all options specified via CLI
14+
- **No environment variables** - use CLI flags instead
15+
- **No hierarchical configuration** - simple argument parsing
16+
17+
## CLI Configuration
18+
19+
Define CLI arguments using `clap` with derive macros:
20+
21+
```rust
22+
use clap::Parser;
23+
use std::path::PathBuf;
24+
25+
#[derive(Parser)]
26+
#[command(name = "stringy")]
27+
#[command(about = "Extract meaningful strings from binary files")]
28+
struct Cli {
29+
/// Input binary file to analyze
30+
#[arg(value_name = "FILE")]
31+
input: PathBuf,
32+
33+
/// Minimum string length
34+
#[arg(short, long, default_value_t = 4)]
35+
min_len: usize,
36+
37+
/// Output format (json, text, yara)
38+
#[arg(short, long, default_value = "text")]
39+
format: String,
40+
41+
/// Only extract strings matching specific tags
42+
#[arg(long)]
43+
only: Option<Vec<String>>,
44+
}
45+
```
46+
47+
## Configuration Validation
48+
49+
Validate CLI arguments:
50+
51+
```rust
52+
impl Cli {
53+
pub fn validate(&self) -> Result<(), StringyError> {
54+
if self.min_len < 1 {
55+
return Err(StringyError::ConfigError(
56+
"Minimum string length must be at least 1".to_string(),
57+
));
58+
}
59+
60+
let valid_formats = ["json", "text", "yara"];
61+
if !valid_formats.contains(&self.format.as_str()) {
62+
return Err(StringyError::ConfigError(format!(
63+
"Invalid output format: {}. Must be one of: {:?}",
64+
self.format, valid_formats
65+
)));
66+
}
67+
68+
Ok(())
69+
}
70+
}
71+
```
72+
73+
## No File-Based Configuration
74+
75+
Stringy intentionally does not support configuration files to keep it simple and portable:
76+
77+
- All configuration comes from CLI arguments
78+
- No need to manage config file locations
79+
- Works the same way across all environments
80+
- Easier to use in scripts and pipelines

0 commit comments

Comments
 (0)