-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add comprehensive testing framework for CONSIM #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: CONSIM Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main, develop, claude/* ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.9', '3.10', '3.11'] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/tests.yml
printf '%s\n' '--- checkout uses ---'
rg -n -C 3 'actions/checkout|persist-credentials|permissions:|pull_request|run:' .github/workflows/tests.ymlRepository: Jacobcdsmith/CONSIM Length of output: 3763 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- workflow ---'
cat -n .github/workflows/tests.yml
printf '%s\n' '--- relevant entries ---'
rg -n -C 3 'actions/checkout|persist-credentials|permissions:|pull_request|run:' .github/workflows/tests.ymlRepository: Jacobcdsmith/CONSIM Length of output: 3766 🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
path = Path(".github/workflows/tests.yml")
lines = path.read_text().splitlines()
checkout_lines = []
for i, line in enumerate(lines):
if "uses: actions/checkout@" in line:
start = i
end = len(lines)
for j in range(i + 1, len(lines)):
stripped = lines[j].strip()
if stripped.startswith("- ") or (stripped and not lines[j].startswith(" ")):
end = j
break
block = lines[start:end]
checkout_lines.append((i + 1, block))
print(f"checkout_steps={len(checkout_lines)}")
for line_no, block in checkout_lines:
print(f"checkout_line={line_no}")
print("has_persist_credentials_false=" +
str(any("persist-credentials: false" in line for line in block)))
print("has_following_run_step=" +
str(any(line.lstrip().startswith("run:") for line in lines[line_no:])))
if len(checkout_lines) != 2:
raise SystemExit("expected exactly two checkout steps")
if any(any("persist-credentials:" in line for line in block)
for _, block in checkout_lines):
raise SystemExit("unexpected persistence setting found")
PYRepository: Jacobcdsmith/CONSIM Length of output: 336 🌐 Web query:
💡 Result: In the actions/checkout official documentation, the persist-credentials input has a default value of true [1][2][3]. When set to true, this input configures the GitHub Actions runner to store the GITHUB_TOKEN (or other provided authentication token or SSH key) in the local git configuration [1][4][3]. This allows subsequent git commands executed within your workflow scripts to run in an authenticated state [1][5][6]. For security, the action removes these credentials during the post-job cleanup phase [1][4][3]. While still enabled by default, newer versions of the action have improved security by storing these credentials in a separate file located under $RUNNER_TEMP rather than directly in.git/config [1][3]. To disable this behavior, you can explicitly set persist-credentials to false in your workflow file [1][4][3]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
python3 - <<'PY'
from pathlib import Path
path = Path(".github/workflows/tests.yml")
lines = path.read_text().splitlines()
checkout_steps = []
for i, line in enumerate(lines):
if "uses: actions/checkout@" in line:
end = len(lines)
for j in range(i + 1, len(lines)):
stripped = lines[j].strip()
if stripped.startswith("- ") or (stripped and not lines[j].startswith(" ")):
end = j
break
checkout_steps.append((i + 1, lines[i:end]))
print(f"checkout_steps={len(checkout_steps)}")
for line_no, block in checkout_steps:
print(f"checkout_line={line_no}")
print("has_persist_credentials_false=" +
str(any("persist-credentials: false" in line for line in block)))
print("has_persist_credentials_setting=" +
str(any("persist-credentials:" in line for line in block)))
if len(checkout_steps) != 2:
raise SystemExit("expected exactly two checkout steps")
if any(any("persist-credentials:" in line for line in block)
for _, block in checkout_steps):
raise SystemExit("unexpected persistence setting found")
PYRepository: Jacobcdsmith/CONSIM Length of output: 356 Disable checkout credential persistence in both jobs. The subsequent repository-controlled commands can access the persisted 🧰 Tools🪛 actionlint (1.7.12)[error] 17-17: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) 🪛 zizmor (1.29.0)[warning] 17-17: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false (artipacked) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
|
Comment on lines
+17
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win Use maintained, consistent action versions throughout the CI documentation. Update the workflow's checkout, setup-python, and codecov action references to maintained majors, and make the copy-paste example in 📍 Affects 2 files
🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install httpx pytest pytest-cov | ||
|
|
||
| - name: Run unit tests | ||
| run: | | ||
| python run_tests.py unit | ||
|
|
||
| - name: Run integration tests | ||
| run: | | ||
| python run_tests.py integration | ||
|
|
||
| - name: Run server tests | ||
| run: | | ||
| python run_tests.py server | ||
|
|
||
| - name: Run all tests with coverage | ||
| run: | | ||
| pytest --cov=src --cov-report=xml --cov-report=term | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| uses: codecov/codecov-action@v3 | ||
| with: | ||
| file: ./coverage.xml | ||
| fail_ci_if_error: false | ||
|
|
||
| performance: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install httpx | ||
|
|
||
| - name: Run performance benchmarks | ||
| run: | | ||
| python run_tests.py performance | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Jacobcdsmith/CONSIM
Length of output: 2336
🏁 Script executed:
Repository: Jacobcdsmith/CONSIM
Length of output: 553
🌐 Web query:
GitHub Actions workflow syntax default GITHUB_TOKEN permissions when permissions is not specified pull_request fork💡 Result:
When a GitHub Actions workflow is triggered by a pull request from a forked repository and no explicit permissions are defined in the workflow file, the GITHUB_TOKEN permissions are automatically adjusted to be read-only [1][2]. This security mechanism applies to all pull request-related events (such as pull_request, pull_request_review, and pull_request_review_comment) that originate from a fork, with the notable exception of the pull_request_target event [1][2]. The specific behavior is as follows: 1. Default Permissions: By default, the GITHUB_TOKEN inherits permissions defined at the repository, organization, or enterprise level [3][2]. 2. Fork Adjustment: If the workflow is triggered by a pull request from a fork, any write permissions are downgraded to read-only [1][4][2]. This ensures that untrusted code contained within a pull request cannot be used to perform unauthorized write operations in the base repository [4][5]. 3. Exception (pull_request_target): The pull_request_target event is an exception to this rule because it runs using the context and code of the base repository's default branch rather than the untrusted code from the fork [5][2][6]. Consequently, it retains read/write permissions (as configured by the repository defaults or explicit workflow permissions), even when the event is triggered by a pull request from a fork [2]. Note that organization and repository administrators can control whether they want to allow write tokens for workflows triggered by pull requests from forks via the Send write tokens to workflows from pull requests setting [1][2]. If this setting is not enabled, the read-only restriction for forks is enforced [1][7][2].
Citations:
How the permissions are calculated for a workflow jobgithub/docs#32398🏁 Script executed:
Repository: Jacobcdsmith/CONSIM
Length of output: 418
Set least-privilege workflow permissions.
This
pull_requestworkflow runs repository-controlled installation and test commands. Same-repository pull requests can inherit broader defaults whenpermissionsis omitted. Add workflow-levelpermissions: contents: readand grant additional permissions only when required.🤖 Prompt for AI Agents
Source: Linters/SAST tools