Skip to content

fix: reapply security fix and docs for v0.2#36

Merged
eaglei15 merged 2 commits intoGenAI-Security-Project:v0.2from
arunsanna:fix/v0.2-reapply-prs
Feb 3, 2026
Merged

fix: reapply security fix and docs for v0.2#36
eaglei15 merged 2 commits intoGenAI-Security-Project:v0.2from
arunsanna:fix/v0.2-reapply-prs

Conversation

@arunsanna
Copy link

Summary

Reapplication of PRs #19 and #28 to the v0.2 branch architecture.

Changes

1. Security Fix: Validate Before Sanitize (from PR #19)

  • Swaps the order of validation and html.escape() sanitization in /generate endpoint
  • Prevents potential bypass attacks where malicious input could be transformed into something that passes validation

2. CONTRIBUTING.md (from PR #28, updated for v0.2)

  • Development setup instructions (Docker + local)
  • Branch naming and PR workflow conventions
  • Updated project architecture diagram reflecting v0.2 structure
  • Testing instructions
  • Community links including weekly call info

Analysis of Original PRs

PR Description Status in v0.2
#18 PURL encoding fix ✅ Already in v0.2
#19 Validate before sanitize 🔧 Reapplied here
#20 Unit test infrastructure ✅ Already in v0.2
#21 Structured logging ✅ Already in v0.2
#22 Schema validation ✅ Already in v0.2
#28 CONTRIBUTING.md 🔧 Reapplied here (updated)

Test Plan

  • Validation tests pass (pytest tests/test_validation.py)
  • Manual test of /generate endpoint with edge case inputs
  • Review CONTRIBUTING.md for accuracy with current structure

Reapply of PR GenAI-Security-Project#19 fix for v0.2 architecture.

Security improvement: Validate model_id BEFORE html.escape() sanitization
to prevent potential bypass attacks where malicious input could be
transformed into something that passes validation.

Example: <script>org/model</script> → &lt;script&gt;org/model&lt;/script&gt;
could slip through if sanitization occurs first.
Reapply of PR GenAI-Security-Project#28 with updates for v0.2 project structure.

- Development setup (Docker + local)
- Branch naming and PR workflow conventions
- Code standards (Python style, logging, imports)
- Updated project architecture diagram for v0.2
- Testing instructions
- Areas welcoming contributions
- Community links including weekly call info
docker run -p 7860:7860 aibom

# Or local Python setup
pip install -r requirements.txt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably worth recommending that people use a venv, right? perhaps we can suggest uv, as it's becoming increasingly an industry standard

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, would you be able to adjust?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

Comment on lines +150 to +157
# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test file
pytest tests/test_validation.py -v
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests in 0.2 are now (sadly for me) in unittest -- I know pytest can run unittest files natively, but I figure it's worth flagging


```bash
# Install test dependencies
pip install -r requirements.txt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should have test dependencies in a separate requirements.dev.txt, or recommend migrating to pyproject.toml for a single document

@eaglei15 eaglei15 merged commit 09e72d0 into GenAI-Security-Project:v0.2 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants