Skip to content

Commit 705156f

Browse files
authored
Merge pull request #102 from talltechy/docs/update-copilot-instructions-secrets-policy
docs: Update Copilot instructions — secrets & PR checklist
2 parents 3dbcc81 + 639217f commit 705156f

File tree

4 files changed

+100
-18
lines changed

4 files changed

+100
-18
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Description
2+
Provide a short, descriptive summary of your changes.
3+
4+
## Related Issue
5+
Fixes # (if applicable)
6+
7+
## Changes Made
8+
- Change 1
9+
- Change 2
10+
11+
## Security Checklist
12+
- [ ] No secrets or hardcoded credentials are introduced in this PR
13+
- [ ] Lint & type checks run (black, flake8, mypy)
14+
- [ ] Tests added/updated where applicable (use mocks/fixtures for external APIs)
15+
- [ ] Documentation and migration notes updated for any public API or behavior changes
16+
- [ ] Security impact reviewed by a maintainer (if applicable)
17+
18+
## Reviewer Suggestions
19+
Please add reviewers (maintainers/security team) for final approval.

.github/copilot-instructions.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,62 @@ source .venv/bin/activate # On Windows: .venv\Scripts\activate
6262
# Install dependencies
6363
pip install -r requirements.txt
6464

65-
# Configure environment
65+
# Configure environment (SECURE)
6666
cp .env.example .env
67-
# Edit .env with credentials
67+
# Create a local `.env` from `.env.example` for development only. Do NOT commit real credentials.
68+
# For production or CI, set secrets using the platform's secret manager (GitHub Secrets, AWS Secrets Manager, Azure Key Vault, etc.)
69+
# Never embed API credentials, tokens, or passwords in code, config files checked into source control, or documentation examples.
6870
```
6971

70-
### Required Environment Variables
72+
### Required Environment Variables (DO NOT HARD-CODE SECRETS)
7173

72-
```bash
73-
INSIGHTVM_API_USERNAME=your_username
74-
INSIGHTVM_API_PASSWORD=your_password
75-
INSIGHTVM_BASE_URL=https://your-console:3780
76-
INSIGHTVM_VERIFY_SSL=false # For self-signed certificates
74+
Provide the following configuration via environment variables or a secret manager. Examples in documentation should show how to reference these variables (e.g. `os.getenv(...)`) but must never include real credential values.
75+
76+
- `INSIGHTVM_API_USERNAME` — InsightVM API username (string); supply via environment or secret manager.
77+
- `INSIGHTVM_API_PASSWORD` — InsightVM API password (secret); store in a secret manager and reference via env var in CI. Never commit this value.
78+
- `INSIGHTVM_BASE_URL` — Full console base URL (include scheme and port), e.g. `https://console.example:3780`.
79+
- `INSIGHTVM_VERIFY_SSL` — Optional boolean; default `true`. Set to `false` only in trusted development/testing environments when using self-signed certificates.
80+
81+
Best practice: Use CI secrets or an external secret manager for production systems and avoid committing `.env` files to the repository.
82+
83+
Secrets Policy (short):
84+
- Never include actual API keys, passwords, tokens, or private keys in source code, documentation, or examples.
85+
- When examples require secrets, use placeholders like `<INSIGHTVM_API_PASSWORD>` or show reading from env vars only.
86+
- Add secret-scanning in CI and pre-commit hooks. Recommended tools: gitleaks, detect-secrets. (Guidance only — do not add secret values here.)
87+
88+
## PR & Commit Checklist (recommended)
89+
90+
Before opening a pull request, ensure:
91+
92+
- No secrets or hardcoded credentials are introduced in the diff.
93+
- Code formatting and static checks pass (black, flake8, mypy).
94+
- Tests cover new functionality; tests use mocks/fixtures for external API calls.
95+
- Documentation and migration notes updated for any public API or behavior changes.
96+
- Add a short security note in the PR description when changes touch auth, secrets, or SSL handling.
97+
98+
## Examples & Tests (no secrets)
99+
100+
- Example code should demonstrate how to read configuration from environment variables, e.g.:
101+
102+
```python
103+
import os
104+
105+
username = os.getenv("INSIGHTVM_API_USERNAME")
106+
password = os.getenv("INSIGHTVM_API_PASSWORD")
107+
base_url = os.getenv("INSIGHTVM_BASE_URL")
77108
```
78109

110+
- Integration or example scripts that require real credentials should never be committed. Tests should use `tests/conftest.py` fixtures and mocked API responses instead of real endpoints.
111+
112+
## API Naming & Compatibility Guidance
113+
114+
- Avoid introducing method names that conflict with `BaseAPI` (for example, do not add `get`, `update`, or `delete` methods to subclasses if those signatures would shadow incompatible parent methods).
115+
- For the Scan Engines client prefer explicit method names such as `get_engine`, `update_engine`, and `delete_engine` to avoid inheritance conflicts. When renaming public methods, include a deprecation wrapper and add a migration note in `MIGRATION.md` and the module's docs.
116+
117+
## SSL Verification Guidance
118+
119+
- Default `INSIGHTVM_VERIFY_SSL` to `true`. Disabling SSL verification (`false`) is allowed only in trusted development or test environments with self-signed certificates and must be documented. Clearly warn users in docs about the security implications of disabling certificate verification.
120+
79121
## Coding Standards
80122

81123
### Python Style Guide

MIGRATION.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,20 @@ ivm_username=myuser
2828
ivm_password=mypass
2929
```
3030

31-
**v2.0 `.env` format:**
31+
**v2.0 `.env` format (DO NOT HARD-CODE SECRETS):**
32+
Provide these variables via environment or a secret manager. Example usages in docs should reference env vars (e.g. `os.getenv(...)`) and must never include real credential values.
33+
3234
```bash
33-
INSIGHTVM_API_USERNAME=myuser
34-
INSIGHTVM_API_PASSWORD=mypass
35-
INSIGHTVM_BASE_URL=https://192.168.10.190:3780
36-
INSIGHTVM_VERIFY_SSL=false # if using self-signed certificates
35+
# INSIGHTVM_API_USERNAME (string) - set in env or secret manager
36+
# INSIGHTVM_API_PASSWORD (secret) - store in secret manager; do NOT commit
37+
# INSIGHTVM_BASE_URL (string) - full console URL, e.g. https://console.example:3780
38+
# INSIGHTVM_VERIFY_SSL (bool) - default true; set to false only for trusted self-signed certs
3739
```
3840

41+
**Security note:** Use CI secrets or an external secret manager (GitHub Secrets, AWS Secrets Manager, Azure Key Vault, etc.) for production; do not store credentials in the repository.
42+
43+
**Copilot guidance:** When using GitHub Copilot to generate or edit code that interacts with authentication or configuration, consult `.github/copilot-instructions.md` for repository-specific guidance on secrets, environment variables, and example generation. Do not add real credentials or sensitive values to code or documentation.
44+
3945
**Migration script for .env:**
4046
```bash
4147
# Combine host and port into base URL

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,24 @@ pip install -r requirements.txt
4141

4242
### Configuration
4343

44-
Create a `.env` file in the project root (see `.env.example` for template):
44+
Create a `.env` file in the project root (see `.env.example` for template).
45+
46+
Do NOT commit real credentials. Use `.env.example` as a template for local development only, and use your platform's secret manager (GitHub Secrets, AWS Secrets Manager, Azure Key Vault, etc.) for CI and production settings.
47+
48+
Example placeholders (do not commit real values):
4549

4650
```bash
47-
# Rapid7 InsightVM API
48-
INSIGHTVM_API_USERNAME=your_username
49-
INSIGHTVM_API_PASSWORD=your_password
51+
# Rapid7 InsightVM API (placeholders - DO NOT COMMIT)
52+
INSIGHTVM_API_USERNAME=<INSIGHTVM_API_USERNAME>
53+
INSIGHTVM_API_PASSWORD=<INSIGHTVM_API_PASSWORD>
5054
INSIGHTVM_BASE_URL=https://your-console:3780
5155

5256
# SSL Configuration (optional)
53-
INSIGHTVM_VERIFY_SSL=false # Set to false for self-signed certificates
57+
INSIGHTVM_VERIFY_SSL=false # Set to false only for trusted development/testing environments
5458
```
5559

60+
See `.github/copilot-instructions.md` for Copilot-specific guidance on generating examples and handling secrets safely.
61+
5662
### Basic Usage
5763

5864
```python
@@ -292,6 +298,15 @@ except requests.exceptions.RequestException as e:
292298
- **HTTPBasicAuth** - Industry-standard authentication pattern
293299
- **Timeout Configuration** - Prevent hanging connections
294300

301+
### Secrets Policy
302+
303+
This project enforces a strict secrets policy to avoid accidental credential leaks:
304+
305+
- Never store API keys, passwords, tokens, or private keys in the repository or documentation examples.
306+
- Examples should reference environment variables or secret manager usage (e.g. `os.getenv('INSIGHTVM_API_PASSWORD')`) and use placeholders such as `<INSIGHTVM_API_PASSWORD>` when needed.
307+
- For development, use a local `.env` (gitignored). For CI and production, use a secret manager (GitHub Secrets, AWS Secrets Manager, Azure Key Vault, etc.).
308+
- See `.github/copilot-instructions.md` for additional guidance used by GitHub Copilot when generating or editing code.
309+
295310
### Security Considerations
296311

297312
⚠️ **Self-Signed Certificates**: When using `verify_ssl=False`, you bypass SSL certificate validation. Only use this in trusted environments with self-signed certificates.

0 commit comments

Comments
 (0)