Skip to content

Commit d4bb1fc

Browse files
committed
Scaffolded Project from local
1 parent e44cd6b commit d4bb1fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4251
-2
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[package]
2+
name = "pe-packer"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "Educational PE packer with Python bindings for malware detection training"
6+
authors = ["AnnMargaret <[email protected]>"]
7+
license = "MIT"
8+
readme = "README.md"
9+
repository = "https://github.com/codeamt/pe-packer"
10+
keywords = ["pe", "packer", "malware", "security", "education"]
11+
categories = ["command-line-utilities", "security"]
12+
13+
[lib]
14+
name = "pe_packer"
15+
crate-type = ["cdylib", "rlib"]
16+
17+
[[bin]]
18+
name = "pe-packer"
19+
path = "src/bin/main.rs"
20+
21+
[dependencies]
22+
goblin = "0.6"
23+
rand = "0.8"
24+
aes = "0.8"
25+
block-modes = "0.9"
26+
sha2 = "0.10"
27+
serde = { version = "1.0", features = ["derive"] }
28+
serde_json = "1.0"
29+
tempfile = "3.6"
30+
log = "0.4"
31+
anyhow = "1.0"
32+
33+
# Python bindings
34+
pyo3 = { version = "0.20", features = ["extension-module", "abi3-py38"] }
35+
numpy = { version = "0.19", optional = true }
36+
37+
[features]
38+
default = []
39+
python = ["pyo3", "numpy"]
40+
cli = []
41+
42+
[package.metadata.maturin]
43+
classifier = [
44+
"Development Status :: 4 - Beta",
45+
"Intended Audience :: Education",
46+
"Intended Audience :: Science/Research",
47+
"License :: OSI Approved :: MIT License",
48+
"License :: OSI Approved :: Apache Software License",
49+
"Programming Language :: Rust",
50+
"Programming Language :: Python :: Implementation :: CPython",
51+
"Topic :: Security",
52+
"Topic :: Software Development :: Libraries",
53+
]
54+
55+
[package.metadata.maturin.python]
56+
requires-python = ">=3.8"

Makefile

Lines changed: 288 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,288 @@
1+
# PE Packer Project Makefile
2+
# Common commands for development, testing, and building
3+
4+
# Configuration
5+
PROJECT_NAME := pe-packer
6+
RUST_PACKAGE_NAME := pe_packer
7+
PYTHON_PACKAGE_NAME := pe_packer
8+
CARGO := cargo
9+
UV := uv
10+
MATURIN := maturin
11+
PYTEST := pytest
12+
PYTHON := python
13+
14+
# Colors for output
15+
GREEN := \033[0;32m
16+
YELLOW := \033[0;33m
17+
RED := \033[0;31m
18+
BLUE := \033[0;34m
19+
NC := \033[0m # No Color
20+
21+
# Default target
22+
.DEFAULT_GOAL := help
23+
24+
.PHONY: help
25+
help: ## Display this help message
26+
@echo "PE Packer Project - Available commands:"
27+
@echo ""
28+
@echo "$(GREEN)Development:$(NC)"
29+
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
30+
@echo ""
31+
@echo "$(GREEN)Python:$(NC)"
32+
@awk 'BEGIN {FS = ":.*?## "} /^py-[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
33+
@echo ""
34+
@echo "$(GREEN)Rust:$(NC)"
35+
@awk 'BEGIN {FS = ":.*?## "} /^rust-[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
36+
@echo ""
37+
@echo "$(GREEN)Testing:$(NC)"
38+
@awk 'BEGIN {FS = ":.*?## "} /^test-[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
39+
@echo ""
40+
@echo "$(GREEN)Build & Release:$(NC)"
41+
@awk 'BEGIN {FS = ":.*?## "} /^(build|release|dist)-[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(NC) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
42+
43+
# Development
44+
.PHONY: setup
45+
setup: venv rust-deps ## Setup development environment
46+
47+
.PHONY: clean
48+
clean: clean-rust clean-python ## Clean all build artifacts
49+
50+
.PHONY: venv
51+
venv: ## Create Python virtual environment with uv
52+
@echo "$(BLUE)Creating virtual environment...$(NC)"
53+
$(UV) venv
54+
@echo "$(GREEN)Virtual environment created$(NC)"
55+
56+
.PHONY: install
57+
install: venv ## Install all dependencies
58+
@echo "$(BLUE)Installing dependencies...$(NC)"
59+
$(UV) sync --group dev --group training
60+
@echo "$(GREEN)Dependencies installed$(NC)"
61+
62+
.PHONY: update
63+
update: ## Update all dependencies
64+
@echo "$(BLUE)Updating dependencies...$(NC)"
65+
$(UV) pip compile --upgrade pyproject.toml
66+
$(UV) sync --group dev --group training
67+
@echo "$(GREEN)Dependencies updated$(NC)"
68+
69+
# Python Commands
70+
.PHONY: py-dev
71+
py-dev: ## Install Python package in development mode
72+
@echo "$(BLUE)Installing Python package in development mode...$(NC)"
73+
$(MATURIN) develop
74+
@echo "$(GREEN)Python package installed$(NC)"
75+
76+
.PHONY: py-build
77+
py-build: ## Build Python package
78+
@echo "$(BLUE)Building Python package...$(NC)"
79+
$(MATURIN) build
80+
@echo "$(GREEN)Python package built$(NC)"
81+
82+
.PHONY: py-clean
83+
py-clean: ## Clean Python build artifacts
84+
@echo "$(BLUE)Cleaning Python build artifacts...$(NC)"
85+
rm -rf build/ dist/ *.egg-info/ .mypy_cache/ .pytest_cache/ .coverage htmlcov/
86+
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
87+
find . -type f -name "*.pyc" -delete
88+
@echo "$(GREEN)Python build artifacts cleaned$(NC)"
89+
90+
.PHONY: py-lint
91+
py-lint: ## Run Python linters
92+
@echo "$(BLUE)Running Python linters...$(NC)"
93+
$(UV) run black --check python/ tests/ examples/
94+
$(UV) run ruff check python/ tests/ examples/
95+
$(UV) run mypy python/ tests/ examples/
96+
@echo "$(GREEN)Python linting completed$(NC)"
97+
98+
.PHONY: py-format
99+
py-format: ## Format Python code
100+
@echo "$(BLUE)Formatting Python code...$(NC)"
101+
$(UV) run black python/ tests/ examples/
102+
$(UV) run ruff check --fix python/ tests/ examples/
103+
@echo "$(GREEN)Python code formatted$(NC)"
104+
105+
.PHONY: py-shell
106+
py-shell: ## Start Python shell with package loaded
107+
@echo "$(BLUE)Starting Python shell...$(NC)"
108+
$(UV) run ipython
109+
110+
# Rust Commands
111+
.PHONY: rust-deps
112+
rust-deps: ## Install Rust dependencies
113+
@echo "$(BLUE)Installing Rust dependencies...$(NC)"
114+
$(CARGO) fetch
115+
@echo "$(GREEN)Rust dependencies installed$(NC)"
116+
117+
.PHONY: rust-build
118+
rust-build: ## Build Rust project
119+
@echo "$(BLUE)Building Rust project...$(NC)"
120+
$(CARGO) build
121+
@echo "$(GREEN)Rust project built$(NC)"
122+
123+
.PHONY: rust-build-release
124+
rust-build-release: ## Build Rust project in release mode
125+
@echo "$(BLUE)Building Rust project (release)...$(NC)"
126+
$(CARGO) build --release
127+
@echo "$(GREEN)Rust release build completed$(NC)"
128+
129+
.PHONY: rust-clean
130+
rust-clean: ## Clean Rust build artifacts
131+
@echo "$(BLUE)Cleaning Rust build artifacts...$(NC)"
132+
$(CARGO) clean
133+
@echo "$(GREEN)Rust build artifacts cleaned$(NC)"
134+
135+
.PHONY: rust-doc
136+
rust-doc: ## Generate Rust documentation
137+
@echo "$(BLUE)Generating Rust documentation...$(NC)"
138+
$(CARGO) doc --no-deps --open
139+
@echo "$(GREEN)Rust documentation generated$(NC)"
140+
141+
.PHONY: rust-clippy
142+
rust-clippy: ## Run Rust clippy linter
143+
@echo "$(BLUE)Running Rust clippy...$(NC)"
144+
$(CARGO) clippy -- -D warnings
145+
@echo "$(GREEN)Rust clippy completed$(NC)"
146+
147+
.PHONY: rust-fmt
148+
rust-fmt: ## Format Rust code
149+
@echo "$(BLUE)Formatting Rust code...$(NC)"
150+
$(CARGO) fmt
151+
@echo "$(GREEN)Rust code formatted$(NC)"
152+
153+
.PHONY: rust-fmt-check
154+
rust-fmt-check: ## Check Rust code formatting
155+
@echo "$(BLUE)Checking Rust code formatting...$(NC)"
156+
$(CARGO) fmt -- --check
157+
@echo "$(GREEN)Rust formatting check completed$(NC)"
158+
159+
# Testing
160+
.PHONY: test
161+
test: test-rust test-python ## Run all tests
162+
163+
.PHONY: test-rust
164+
test-rust: ## Run Rust tests
165+
@echo "$(BLUE)Running Rust tests...$(NC)"
166+
$(CARGO) test
167+
@echo "$(GREEN)Rust tests completed$(NC)"
168+
169+
.PHONY: test-python
170+
test-python: ## Run Python tests
171+
@echo "$(BLUE)Running Python tests...$(NC)"
172+
$(UV) run pytest tests/ -v --cov=$(PYTHON_PACKAGE_NAME) --cov-report=html
173+
@echo "$(GREEN)Python tests completed$(NC)"
174+
175+
.PHONY: test-python-fast
176+
test-python-fast: ## Run Python tests without coverage
177+
@echo "$(BLUE)Running Python tests (fast)...$(NC)"
178+
$(UV) run pytest tests/ -v
179+
@echo "$(GREEN)Python tests completed$(NC)"
180+
181+
.PHONY: test-examples
182+
test-examples: ## Test example code
183+
@echo "$(BLUE)Testing examples...$(NC)"
184+
$(UV) run python examples/training_data_generation.py --dry-run
185+
@echo "$(GREEN)Example tests completed$(NC)"
186+
187+
.PHONY: test-benchmarks
188+
test-benchmarks: ## Run benchmarks
189+
@echo "$(BLUE)Running benchmarks...$(NC)"
190+
$(CARGO) bench
191+
$(UV) run python benchmarks/python_performance.py
192+
@echo "$(GREEN)Benchmarks completed$(NC)"
193+
194+
# Build & Distribution
195+
.PHONY: build
196+
build: rust-build-release py-build ## Build both Rust and Python packages
197+
198+
.PHONY: dist
199+
dist: ## Build distribution packages
200+
@echo "$(BLUE)Building distribution packages...$(NC)"
201+
$(MATURIN) build --release
202+
@echo "$(GREEN)Distribution packages built$(NC)"
203+
204+
.PHONY: dist-rust
205+
dist-rust: ## Build Rust distribution
206+
@echo "$(BLUE)Building Rust distribution...$(NC)"
207+
$(CARGO) build --release
208+
@echo "$(GREEN)Rust distribution built$(NC)"
209+
210+
.PHONY: dist-python
211+
dist-python: ## Build Python wheels
212+
@echo "$(BLUE)Building Python wheels...$(NC)"
213+
$(MATURIN) build --release
214+
@echo "$(GREEN)Python wheels built$(NC)"
215+
216+
.PHONY: release
217+
release: test build ## Prepare release (run tests and build)
218+
@echo "$(GREEN)Release preparation completed$(NC)"
219+
220+
.PHONY: release-dry-run
221+
release-dry-run: ## Dry run release process
222+
@echo "$(BLUE)Running release dry run...$(NC)"
223+
$(MAKE) test
224+
$(MAKE) rust-fmt-check
225+
$(MAKE) rust-clippy
226+
$(MAKE) py-lint
227+
$(MAKE) build
228+
@echo "$(GREEN)Release dry run completed$(NC)"
229+
230+
# Utility Commands
231+
.PHONY: generate-training-data
232+
generate-training-data: ## Generate training data samples
233+
@echo "$(BLUE)Generating training data...$(NC)"
234+
$(UV) run python examples/training_data_generation.py
235+
@echo "$(GREEN)Training data generated$(NC)"
236+
237+
.PHONY: run-example
238+
run-example: ## Run basic packing example
239+
@echo "$(BLUE)Running packing example...$(NC)"
240+
$(UV) run python examples/basic_packing.py
241+
@echo "$(GREEN)Example completed$(NC)"
242+
243+
.PHONY: docker-build
244+
docker-build: ## Build Docker image
245+
@echo "$(BLUE)Building Docker image...$(NC)"
246+
docker build -t $(PROJECT_NAME) .
247+
@echo "$(GREEN)Docker image built$(NC)"
248+
249+
.PHONY: docker-run
250+
docker-run: ## Run project in Docker
251+
@echo "$(BLUE)Running in Docker...$(NC)"
252+
docker run -it --rm $(PROJECT_NAME)
253+
@echo "$(GREEN)Docker run completed$(NC)"
254+
255+
# Quality Assurance
256+
.PHONY: qa
257+
qa: rust-fmt-check rust-clippy py-lint test ## Run all quality checks
258+
@echo "$(GREEN)All quality checks passed$(NC)"
259+
260+
.PHONY: pre-commit
261+
pre-commit: rust-fmt py-format test ## Run pre-commit checks
262+
@echo "$(GREEN)Pre-commit checks completed$(NC)"
263+
264+
# Monitoring
265+
.PHONY: watch-rust
266+
watch-rust: ## Watch Rust files and run tests on change
267+
@echo "$(BLUE)Watching Rust files...$(NC)"
268+
$(CARGO) watch -x test
269+
270+
.PHONY: watch-python
271+
watch-python: ## Watch Python files and run tests on change
272+
@echo "$(BLUE)Watching Python files...$(NC)"
273+
$(UV) run ptw --now .
274+
275+
.PHONY: size
276+
size: ## Check binary sizes
277+
@echo "$(BLUE)Binary sizes:$(NC)"
278+
@ls -lh target/release/$(RUST_PACKAGE_NAME)* 2>/dev/null || echo "No Rust binaries found"
279+
@ls -lh dist/*.whl 2>/dev/null || echo "No Python wheels found"
280+
281+
# Install development tools
282+
.PHONY: install-tools
283+
install-tools: ## Install development tools
284+
@echo "$(BLUE)Installing development tools...$(NC)"
285+
cargo install cargo-watch
286+
cargo install cargo-bloat
287+
$(UV) pip install pre-commit
288+
@echo "$(GREEN)Development tools installed$(NC)"

0 commit comments

Comments
 (0)