|
| 1 | +# Contributing to SecAI OS |
| 2 | + |
| 3 | +Thank you for your interest in contributing to SecAI OS. This document explains |
| 4 | +how to set up your development environment, run tests, and submit changes. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +| Tool | Minimum Version | Purpose | |
| 9 | +|---|---|---| |
| 10 | +| Go | 1.22+ | Build Go services (registry, tool-firewall, airlock) | |
| 11 | +| Python | 3.11+ | Build Python services (quarantine, UI, search mediator) | |
| 12 | +| shellcheck | Latest | Lint shell scripts | |
| 13 | +| git | 2.x | Version control | |
| 14 | + |
| 15 | +Optional but recommended: |
| 16 | + |
| 17 | +- `gofmt` (included with Go) for formatting Go code. |
| 18 | +- `pip` or a virtual-environment manager (`venv`, `uv`) for Python dependencies. |
| 19 | +- `cosign` for verifying container image signatures. |
| 20 | + |
| 21 | +## Local Development Setup |
| 22 | + |
| 23 | +### 1. Clone the Repository |
| 24 | + |
| 25 | +```bash |
| 26 | +git clone https://github.com/SecAI-Hub/SecAI_OS.git |
| 27 | +cd SecAI_OS |
| 28 | +``` |
| 29 | + |
| 30 | +### 2. Build Go Services |
| 31 | + |
| 32 | +```bash |
| 33 | +cd services/registry && go build ./... && cd ../.. |
| 34 | +cd services/tool-firewall && go build ./... && cd ../.. |
| 35 | +cd services/airlock && go build ./... && cd ../.. |
| 36 | +``` |
| 37 | + |
| 38 | +### 3. Install Python Dependencies |
| 39 | + |
| 40 | +```bash |
| 41 | +python3 -m venv .venv |
| 42 | +source .venv/bin/activate |
| 43 | +pip install -r services/quarantine/requirements.txt |
| 44 | +pip install -r services/ui/requirements.txt |
| 45 | +pip install -r services/search-mediator/requirements.txt |
| 46 | +pip install pytest |
| 47 | +``` |
| 48 | + |
| 49 | +### 4. Verify Shell Scripts |
| 50 | + |
| 51 | +```bash |
| 52 | +shellcheck files/system/usr/libexec/secure-ai/*.sh |
| 53 | +``` |
| 54 | + |
| 55 | +## Running Tests |
| 56 | + |
| 57 | +### Go Tests (26 tests) |
| 58 | + |
| 59 | +```bash |
| 60 | +cd services/registry && go test ./... -v && cd ../.. |
| 61 | +cd services/tool-firewall && go test ./... -v && cd ../.. |
| 62 | +cd services/airlock && go test ./... -v && cd ../.. |
| 63 | +``` |
| 64 | + |
| 65 | +### Python Tests (595+ tests) |
| 66 | + |
| 67 | +```bash |
| 68 | +pytest tests/ -v |
| 69 | +``` |
| 70 | + |
| 71 | +### Shell Linting |
| 72 | + |
| 73 | +```bash |
| 74 | +shellcheck files/system/usr/libexec/secure-ai/*.sh |
| 75 | +``` |
| 76 | + |
| 77 | +### Run Everything |
| 78 | + |
| 79 | +```bash |
| 80 | +# Go |
| 81 | +for svc in registry tool-firewall airlock; do |
| 82 | + (cd "services/$svc" && go test ./... -v) |
| 83 | +done |
| 84 | + |
| 85 | +# Python |
| 86 | +pytest tests/ -v |
| 87 | + |
| 88 | +# Shell |
| 89 | +shellcheck files/system/usr/libexec/secure-ai/*.sh |
| 90 | +``` |
| 91 | + |
| 92 | +## Coding Standards |
| 93 | + |
| 94 | +### Go |
| 95 | + |
| 96 | +- Format all Go code with `gofmt`. CI will reject unformatted code. |
| 97 | +- Follow standard Go conventions (effective Go, Go Code Review Comments). |
| 98 | +- Export only what is necessary; keep package APIs minimal. |
| 99 | + |
| 100 | +### Python |
| 101 | + |
| 102 | +- Follow [PEP 8](https://peps.python.org/pep-0008/). |
| 103 | +- Use type hints where practical. |
| 104 | +- Keep functions focused and testable. |
| 105 | + |
| 106 | +### Shell |
| 107 | + |
| 108 | +- Target POSIX sh unless bash-specific features are required. |
| 109 | +- All scripts must pass `shellcheck` with zero warnings. |
| 110 | +- Use `set -euo pipefail` at the top of bash scripts. |
| 111 | + |
| 112 | +### General |
| 113 | + |
| 114 | +- Keep commits atomic -- one logical change per commit. |
| 115 | +- Write clear, descriptive variable and function names. |
| 116 | +- Add or update tests for any new functionality. |
| 117 | + |
| 118 | +## Pull Request Process |
| 119 | + |
| 120 | +1. **Branch from `main`.** Create a feature branch with a descriptive name: |
| 121 | + ``` |
| 122 | + git checkout -b feat/short-description |
| 123 | + ``` |
| 124 | + |
| 125 | +2. **Make your changes.** Follow the coding standards above. |
| 126 | + |
| 127 | +3. **Run all tests locally.** Ensure Go tests, Python tests, and shellcheck |
| 128 | + all pass before pushing. |
| 129 | + |
| 130 | +4. **Sign your commits.** Use `git commit -s` to add a Signed-off-by line, |
| 131 | + or configure GPG/SSH signing. |
| 132 | + |
| 133 | +5. **Push and open a PR.** Target the `main` branch. |
| 134 | + |
| 135 | +6. **Describe your changes.** In the PR description, explain: |
| 136 | + - What the change does and why it is needed. |
| 137 | + - How it was tested. |
| 138 | + - Any relevant issue numbers (use `Closes #N` or `Fixes #N`). |
| 139 | + |
| 140 | +7. **Wait for CI.** All checks must pass before a PR will be reviewed. |
| 141 | + |
| 142 | +8. **Respond to review feedback.** Push additional commits to address review |
| 143 | + comments rather than force-pushing. |
| 144 | + |
| 145 | +## Commit Message Format |
| 146 | + |
| 147 | +Use the following format for commit messages: |
| 148 | + |
| 149 | +``` |
| 150 | +<type>: <short summary> |
| 151 | +
|
| 152 | +<optional longer description> |
| 153 | +
|
| 154 | +Signed-off-by: Your Name <your.email@example.com> |
| 155 | +``` |
| 156 | + |
| 157 | +Where `<type>` is one of: |
| 158 | + |
| 159 | +| Type | Meaning | |
| 160 | +|---|---| |
| 161 | +| `feat` | New feature | |
| 162 | +| `fix` | Bug fix | |
| 163 | +| `docs` | Documentation only | |
| 164 | +| `test` | Adding or updating tests | |
| 165 | +| `refactor` | Code change that neither fixes a bug nor adds a feature | |
| 166 | +| `chore` | Build, CI, or tooling changes | |
| 167 | +| `security` | Security-related change | |
| 168 | + |
| 169 | +Example: |
| 170 | + |
| 171 | +``` |
| 172 | +feat: add tensor-level scanning to quarantine pipeline |
| 173 | +
|
| 174 | +Scan individual tensors in GGUF files for anomalous shapes and |
| 175 | +unexpected data types before promoting models to the trusted store. |
| 176 | +
|
| 177 | +Signed-off-by: Jane Doe <jane@example.com> |
| 178 | +``` |
| 179 | + |
| 180 | +## Reporting Issues |
| 181 | + |
| 182 | +- **Bugs:** Open a [GitHub Issue](https://github.com/SecAI-Hub/SecAI_OS/issues). |
| 183 | +- **Security vulnerabilities:** See [SECURITY.md](SECURITY.md). |
| 184 | +- **Questions:** Use [GitHub Discussions](https://github.com/SecAI-Hub/SecAI_OS/discussions). |
| 185 | + |
| 186 | +## License |
| 187 | + |
| 188 | +By contributing to SecAI OS, you agree that your contributions will be licensed |
| 189 | +under the [Apache License 2.0](LICENSE). |
0 commit comments