Skip to content

Commit 16e9d04

Browse files
authored
Merge pull request #21 from kevinnft/feat/executor-tests-security
feat(executor): add comprehensive test suite and security hardening for ToolExecutor
2 parents a953199 + 393e4b6 commit 16e9d04

13 files changed

Lines changed: 907 additions & 29 deletions

File tree

.editorconfig

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# EditorConfig: https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[*.rs]
16+
indent_size = 4
17+
18+
[Makefile]
19+
indent_style = tab
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug or unexpected behavior
4+
title: "fix: "
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
## Describe the bug
10+
A clear and concise description of the bug.
11+
12+
## To Reproduce
13+
Steps to reproduce the behavior:
14+
1. Go to '...'
15+
2. Click on '...'
16+
3. See error
17+
18+
## Expected behavior
19+
What you expected to happen.
20+
21+
## Screenshots
22+
If applicable, add screenshots to help explain.
23+
24+
## Environment
25+
- OS: [e.g. Windows 11, macOS 14, Ubuntu 24.04]
26+
- enowX-Coder version: [e.g. latest main]
27+
28+
## Additional context
29+
Add any other context about the problem here.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea or enhancement
4+
title: "feat: "
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
## Is your feature request related to a problem?
10+
A clear and concise description of what the problem is.
11+
12+
## Describe the solution you'd like
13+
What you want to happen.
14+
15+
## Describe alternatives you've considered
16+
Other solutions or features you've considered.
17+
18+
## Use case
19+
Who would benefit from this feature? How?
20+
21+
## Additional context
22+
Add any other context, mockups, or screenshots here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Description
2+
<!-- Describe what this PR does and why it's needed -->
3+
4+
## Type of Change
5+
- [ ] Bug fix (non-breaking change that fixes an issue)
6+
- [ ] New feature
7+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work)
8+
- [ ] Documentation update
9+
- [ ] Refactor (no behavior change)
10+
11+
## How Has This Been Tested?
12+
<!-- Describe the tests that you ran to verify your changes -->
13+
14+
- [ ] `cargo clippy -- -D warnings` passes (Rust)
15+
- [ ] `bunx tsc --noEmit` passes (TypeScript)
16+
- [ ] Manual testing steps below
17+
18+
## Checklist
19+
- [ ] My code follows the project's style guidelines
20+
- [ ] I have performed a self-review of my code
21+
- [ ] I have commented my code, particularly in hard-to-understand areas
22+
- [ ] I have made corresponding changes to the documentation
23+
- [ ] I have added tests that prove my fix is effective or that my feature works

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
frontend:
11+
name: Frontend (TypeScript)
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
19+
- name: Install dependencies
20+
run: bun install --frozen-lockfile
21+
22+
- name: Type check
23+
run: bunx tsc --noEmit
24+
25+
- name: Lint
26+
run: bun lint 2>/dev/null || echo "No lint script"
27+
28+
- name: Build
29+
run: bun run build
30+
31+
backend:
32+
name: Backend (Rust)
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Install system deps
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
41+
42+
- name: Install Rust
43+
uses: dtolnay/rust-toolchain@stable
44+
45+
- name: Cache cargo registry
46+
uses: Swatinem/rust-cache@v2
47+
with:
48+
workspaces: src-tauri
49+
50+
- name: Clippy (deny warnings)
51+
run: cd src-tauri && cargo clippy -- -D warnings
52+
53+
- name: Tests
54+
run: cd src-tauri && cargo test
55+
56+
- name: Build check
57+
run: cd src-tauri && cargo check

CONTRIBUTING.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Contributing to enowX-Coder
2+
3+
Thank you for your interest in contributing! enowX-Coder is a Tauri-based AI code editor built with Rust + React + TypeScript.
4+
5+
## 🏗️ Architecture
6+
7+
- **Backend**: `src-tauri/` — Rust (Tauri v2)
8+
- **Frontend**: `src/` — React + TypeScript
9+
- **Database**: SQLite via `sqlx`
10+
- **AI**: Streaming chat via OpenAI/Anthropic compatible providers
11+
12+
## 🚀 Getting Started
13+
14+
```bash
15+
# Clone the repository
16+
git clone https://github.com/kevinnft/enowX-Coder.git
17+
cd enowX-Coder
18+
19+
# Install frontend dependencies
20+
bun install
21+
22+
# Run in development mode
23+
cargo tauri dev
24+
```
25+
26+
## 📝 Commit Convention
27+
28+
We use [Conventional Commits](https://www.conventionalcommits.org/):
29+
30+
```
31+
<type>(<scope>): <description>
32+
```
33+
34+
| Type | Description |
35+
|---|---|
36+
| `feat` | New feature |
37+
| `fix` | Bug fix |
38+
| `refactor` | Code restructure, no behavior change |
39+
| `chore` | Maintenance, tooling |
40+
| `docs` | Documentation |
41+
| `build` | Dependencies, build config |
42+
| `test` | Adding/fixing tests |
43+
| `perf` | Performance improvement |
44+
45+
Examples:
46+
```
47+
feat(chat): add model selector dropdown
48+
fix(editor): resolve tab sync issue on file switch
49+
refactor(agents): simplify prompt construction
50+
docs: add setup guide for Linux
51+
```
52+
53+
## 🌿 Git Workflow
54+
55+
- **Trunk-based development**: branch from `main`, short-lived branches only
56+
- Delete branches after merge
57+
- Never force push to `main`
58+
- Use `git add -p` (interactive staging), never blind `git add .`
59+
60+
## 📋 Code Standards
61+
62+
### Rust
63+
- Use `AppError` enum with `thiserror` — never `unwrap()` in production paths
64+
- Commands are thin wrappers — all business logic in `services/`
65+
- All Tauri commands must be `async`
66+
- Use `#[serde(rename_all = "camelCase")]` on structs sent to frontend
67+
68+
### TypeScript / React
69+
- Strict TypeScript — no `as any`, no `@ts-ignore`
70+
- Follow existing component patterns
71+
72+
## 🧪 Pull Requests
73+
74+
Before submitting a PR:
75+
1. Make sure `cargo clippy -- -D warnings` passes
76+
2. Make sure `bunx tsc --noEmit` passes
77+
3. Squash your commits into logical units
78+
4. Write a clear description of what changes and why
79+
80+
## 🤝 Code of Conduct
81+
82+
We follow Contributor Covenant. Be respectful, constructive, and inclusive.

SECURITY.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
|---|---|
7+
| Latest release ||
8+
9+
## Reporting a Vulnerability
10+
11+
We take security seriously. If you discover a security vulnerability, please:
12+
13+
1. **Do NOT open a public issue**
14+
2. Email: `kevinnft@users.noreply.github.com`
15+
3. Include:
16+
- Description of the vulnerability
17+
- Steps to reproduce
18+
- Potential impact
19+
- Suggested fix (optional)
20+
21+
We will respond within 48 hours and work with you to resolve the issue.
22+
23+
## Security Practices
24+
25+
- API keys and provider credentials are stored locally only (`~/.local/share/enowx-coder/`)
26+
- No telemetry or data collection
27+
- SQLite database is local-only
28+
- Provider API calls use HTTPS only
29+
- All Rust code uses safe error handling (no `unwrap()` in production paths)

src-tauri/clippy.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
disallowed-methods = [
2+
{ path = "std::option::Option::unwrap", reason = "use expect() with a message or handle the None case" },
3+
{ path = "std::result::Result::unwrap", reason = "use expect() with a message or handle the Err case" },
4+
{ path = "std::result::Result::expect", reason = "use proper error handling with AppError" },
5+
]

src-tauri/rustfmt.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
edition = "2021"
2+
max_width = 100
3+
newline_style = "Unix"
4+
use_field_init_shorthand = true
5+
reorder_imports = true

src-tauri/src/error.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,32 @@ impl From<tauri::Error> for AppError {
6767
Self::Tauri(value.to_string())
6868
}
6969
}
70+
71+
#[cfg(test)]
72+
mod tests {
73+
use super::*;
74+
75+
#[test]
76+
fn test_not_found_error() {
77+
let err = AppError::NotFound("resource".to_string());
78+
assert_eq!(err.to_string(), "Not found: resource");
79+
}
80+
81+
#[test]
82+
fn test_validation_error() {
83+
let err = AppError::Validation("invalid input".to_string());
84+
assert_eq!(err.to_string(), "Validation error: invalid input");
85+
}
86+
87+
#[test]
88+
fn test_cancelled_error() {
89+
let err = AppError::Cancelled;
90+
assert_eq!(err.to_string(), "Cancelled");
91+
}
92+
93+
#[test]
94+
fn test_error_to_string() {
95+
let err: String = AppError::NotFound("test").into();
96+
assert_eq!(err, "Not found: test");
97+
}
98+
}

0 commit comments

Comments
 (0)