asap-protocol 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- asap_protocol-0.1.0/.cursor/commands/code-quality-review.md +54 -0
- asap_protocol-0.1.0/.cursor/commands/create-prd.md +61 -0
- asap_protocol-0.1.0/.cursor/commands/generate-tasks.md +64 -0
- asap_protocol-0.1.0/.cursor/commands/reflect.md +13 -0
- asap_protocol-0.1.0/.cursor/commands/security-pr-review.md +192 -0
- asap_protocol-0.1.0/.cursor/commands/security-review.md +58 -0
- asap_protocol-0.1.0/.cursor/commands/task-list-development.md +92 -0
- asap_protocol-0.1.0/.cursor/commands/test-coverage-review.md +51 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/pr-8-review-temp.md +45 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/pre-pypi-release-review.md +582 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/security-review-report.md +828 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/sprint3-code-review.md +674 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/sprint4-code-review.md +77 -0
- asap_protocol-0.1.0/.cursor/dev-planning/code-review/sprint5-code-review.md +382 -0
- asap_protocol-0.1.0/.cursor/dev-planning/prd/prd-asap-implementation.md +338 -0
- asap_protocol-0.1.0/.cursor/dev-planning/tasks/tasks-prd-asap-implementation.md +850 -0
- asap_protocol-0.1.0/.cursor/dev-planning/tasks/tasks-security-review-report.md +343 -0
- asap_protocol-0.1.0/.cursor/dev-planning/tasks/tasks-sprint3-improvements.md +371 -0
- asap_protocol-0.1.0/.cursor/docs/general-specs.md +1196 -0
- asap_protocol-0.1.0/.cursor/docs/sprint-planning.md +240 -0
- asap_protocol-0.1.0/.cursor/rules/architecture-principles.mdc +31 -0
- asap_protocol-0.1.0/.cursor/rules/git-commits.mdc +36 -0
- asap_protocol-0.1.0/.cursor/rules/python-best-practices.mdc +36 -0
- asap_protocol-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +71 -0
- asap_protocol-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +44 -0
- asap_protocol-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +32 -0
- asap_protocol-0.1.0/.github/workflows/ci.yml +88 -0
- asap_protocol-0.1.0/.github/workflows/docs.yml +32 -0
- asap_protocol-0.1.0/.github/workflows/release.yml +36 -0
- asap_protocol-0.1.0/.gitignore +167 -0
- asap_protocol-0.1.0/CHANGELOG.md +113 -0
- asap_protocol-0.1.0/CODE_OF_CONDUCT.md +18 -0
- asap_protocol-0.1.0/CONTRIBUTING.md +49 -0
- asap_protocol-0.1.0/LICENSE +190 -0
- asap_protocol-0.1.0/PKG-INFO +251 -0
- asap_protocol-0.1.0/README.md +209 -0
- asap_protocol-0.1.0/SECURITY.md +44 -0
- asap_protocol-0.1.0/benchmarks/README.md +167 -0
- asap_protocol-0.1.0/benchmarks/__init__.py +14 -0
- asap_protocol-0.1.0/benchmarks/benchmark_models.py +288 -0
- asap_protocol-0.1.0/benchmarks/benchmark_transport.py +239 -0
- asap_protocol-0.1.0/benchmarks/conftest.py +75 -0
- asap_protocol-0.1.0/docs/api-reference.md +45 -0
- asap_protocol-0.1.0/docs/error-handling.md +49 -0
- asap_protocol-0.1.0/docs/index.md +75 -0
- asap_protocol-0.1.0/docs/metrics.md +426 -0
- asap_protocol-0.1.0/docs/migration.md +506 -0
- asap_protocol-0.1.0/docs/observability.md +53 -0
- asap_protocol-0.1.0/docs/security.md +538 -0
- asap_protocol-0.1.0/docs/state-management.md +537 -0
- asap_protocol-0.1.0/docs/testing.md +51 -0
- asap_protocol-0.1.0/docs/transport.md +496 -0
- asap_protocol-0.1.0/mkdocs.yml +62 -0
- asap_protocol-0.1.0/pyproject.toml +132 -0
- asap_protocol-0.1.0/schemas/entities/agent.schema.json +31 -0
- asap_protocol-0.1.0/schemas/entities/artifact.schema.json +44 -0
- asap_protocol-0.1.0/schemas/entities/conversation.schema.json +46 -0
- asap_protocol-0.1.0/schemas/entities/manifest.schema.json +225 -0
- asap_protocol-0.1.0/schemas/entities/message.schema.json +61 -0
- asap_protocol-0.1.0/schemas/entities/state_snapshot.schema.json +49 -0
- asap_protocol-0.1.0/schemas/entities/task.schema.json +83 -0
- asap_protocol-0.1.0/schemas/envelope.schema.json +108 -0
- asap_protocol-0.1.0/schemas/parts/data_part.schema.json +37 -0
- asap_protocol-0.1.0/schemas/parts/file_part.schema.json +42 -0
- asap_protocol-0.1.0/schemas/parts/resource_part.schema.json +23 -0
- asap_protocol-0.1.0/schemas/parts/template_part.schema.json +30 -0
- asap_protocol-0.1.0/schemas/parts/text_part.schema.json +23 -0
- asap_protocol-0.1.0/schemas/payloads/artifact_notify.schema.json +35 -0
- asap_protocol-0.1.0/schemas/payloads/mcp_resource_data.schema.json +23 -0
- asap_protocol-0.1.0/schemas/payloads/mcp_resource_fetch.schema.json +16 -0
- asap_protocol-0.1.0/schemas/payloads/mcp_tool_call.schema.json +43 -0
- asap_protocol-0.1.0/schemas/payloads/mcp_tool_result.schema.json +49 -0
- asap_protocol-0.1.0/schemas/payloads/message_send.schema.json +43 -0
- asap_protocol-0.1.0/schemas/payloads/state_query.schema.json +29 -0
- asap_protocol-0.1.0/schemas/payloads/state_restore.schema.json +22 -0
- asap_protocol-0.1.0/schemas/payloads/task_cancel.schema.json +29 -0
- asap_protocol-0.1.0/schemas/payloads/task_request.schema.json +56 -0
- asap_protocol-0.1.0/schemas/payloads/task_response.schema.json +78 -0
- asap_protocol-0.1.0/schemas/payloads/task_update.schema.json +79 -0
- asap_protocol-0.1.0/scripts/export_schemas.py +26 -0
- asap_protocol-0.1.0/src/asap/__init__.py +7 -0
- asap_protocol-0.1.0/src/asap/cli.py +220 -0
- asap_protocol-0.1.0/src/asap/errors.py +150 -0
- asap_protocol-0.1.0/src/asap/examples/README.md +25 -0
- asap_protocol-0.1.0/src/asap/examples/__init__.py +1 -0
- asap_protocol-0.1.0/src/asap/examples/coordinator.py +184 -0
- asap_protocol-0.1.0/src/asap/examples/echo_agent.py +100 -0
- asap_protocol-0.1.0/src/asap/examples/run_demo.py +120 -0
- asap_protocol-0.1.0/src/asap/models/__init__.py +146 -0
- asap_protocol-0.1.0/src/asap/models/base.py +55 -0
- asap_protocol-0.1.0/src/asap/models/constants.py +14 -0
- asap_protocol-0.1.0/src/asap/models/entities.py +410 -0
- asap_protocol-0.1.0/src/asap/models/enums.py +71 -0
- asap_protocol-0.1.0/src/asap/models/envelope.py +94 -0
- asap_protocol-0.1.0/src/asap/models/ids.py +55 -0
- asap_protocol-0.1.0/src/asap/models/parts.py +207 -0
- asap_protocol-0.1.0/src/asap/models/payloads.py +423 -0
- asap_protocol-0.1.0/src/asap/models/types.py +39 -0
- asap_protocol-0.1.0/src/asap/observability/__init__.py +43 -0
- asap_protocol-0.1.0/src/asap/observability/logging.py +216 -0
- asap_protocol-0.1.0/src/asap/observability/metrics.py +399 -0
- asap_protocol-0.1.0/src/asap/schemas.py +203 -0
- asap_protocol-0.1.0/src/asap/state/__init__.py +22 -0
- asap_protocol-0.1.0/src/asap/state/machine.py +86 -0
- asap_protocol-0.1.0/src/asap/state/snapshot.py +265 -0
- asap_protocol-0.1.0/src/asap/transport/__init__.py +84 -0
- asap_protocol-0.1.0/src/asap/transport/client.py +399 -0
- asap_protocol-0.1.0/src/asap/transport/handlers.py +444 -0
- asap_protocol-0.1.0/src/asap/transport/jsonrpc.py +190 -0
- asap_protocol-0.1.0/src/asap/transport/middleware.py +359 -0
- asap_protocol-0.1.0/src/asap/transport/server.py +739 -0
- asap_protocol-0.1.0/tests/conftest.py +73 -0
- asap_protocol-0.1.0/tests/e2e/__init__.py +1 -0
- asap_protocol-0.1.0/tests/e2e/test_two_agents.py +41 -0
- asap_protocol-0.1.0/tests/examples/__init__.py +1 -0
- asap_protocol-0.1.0/tests/examples/test_coordinator.py +120 -0
- asap_protocol-0.1.0/tests/examples/test_echo_agent.py +140 -0
- asap_protocol-0.1.0/tests/models/test_base.py +115 -0
- asap_protocol-0.1.0/tests/models/test_entities.py +865 -0
- asap_protocol-0.1.0/tests/models/test_enums.py +251 -0
- asap_protocol-0.1.0/tests/models/test_envelope.py +256 -0
- asap_protocol-0.1.0/tests/models/test_ids.py +91 -0
- asap_protocol-0.1.0/tests/models/test_parts.py +429 -0
- asap_protocol-0.1.0/tests/models/test_payloads.py +645 -0
- asap_protocol-0.1.0/tests/observability/__init__.py +1 -0
- asap_protocol-0.1.0/tests/observability/test_logging.py +181 -0
- asap_protocol-0.1.0/tests/observability/test_metrics.py +489 -0
- asap_protocol-0.1.0/tests/state/__init__.py +1 -0
- asap_protocol-0.1.0/tests/state/test_machine.py +239 -0
- asap_protocol-0.1.0/tests/state/test_snapshot.py +675 -0
- asap_protocol-0.1.0/tests/test_cli.py +334 -0
- asap_protocol-0.1.0/tests/test_errors.py +251 -0
- asap_protocol-0.1.0/tests/test_schemas.py +214 -0
- asap_protocol-0.1.0/tests/test_version.py +6 -0
- asap_protocol-0.1.0/tests/transport/__init__.py +1 -0
- asap_protocol-0.1.0/tests/transport/test_client.py +671 -0
- asap_protocol-0.1.0/tests/transport/test_handlers.py +932 -0
- asap_protocol-0.1.0/tests/transport/test_integration.py +426 -0
- asap_protocol-0.1.0/tests/transport/test_jsonrpc.py +419 -0
- asap_protocol-0.1.0/tests/transport/test_middleware.py +440 -0
- asap_protocol-0.1.0/tests/transport/test_server.py +1015 -0
- asap_protocol-0.1.0/uv.lock +1319 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert code quality reviewer with deep expertise in software engineering best practices, clean code principles, and maintainable architecture. Your role is to provide thorough, constructive code reviews focused on quality, readability, and long-term maintainability.
|
|
8
|
+
|
|
9
|
+
When reviewing code, you will:
|
|
10
|
+
|
|
11
|
+
**Clean Code Analysis:**
|
|
12
|
+
|
|
13
|
+
- Evaluate naming conventions for clarity and descriptiveness
|
|
14
|
+
- Assess function and method sizes for single responsibility adherence
|
|
15
|
+
- Check for code duplication and suggest DRY improvements
|
|
16
|
+
- Identify overly complex logic that could be simplified
|
|
17
|
+
- Verify proper separation of concerns
|
|
18
|
+
|
|
19
|
+
**Error Handling & Edge Cases:**
|
|
20
|
+
|
|
21
|
+
- Identify missing error handling for potential failure points
|
|
22
|
+
- Evaluate the robustness of input validation
|
|
23
|
+
- Check for proper handling of null/undefined values
|
|
24
|
+
- Assess edge case coverage (empty arrays, boundary conditions, etc.)
|
|
25
|
+
- Verify appropriate use of try-catch blocks and error propagation
|
|
26
|
+
|
|
27
|
+
**Readability & Maintainability:**
|
|
28
|
+
|
|
29
|
+
- Evaluate code structure and organization
|
|
30
|
+
- Check for appropriate use of comments (avoiding over-commenting obvious code)
|
|
31
|
+
- Assess the clarity of control flow
|
|
32
|
+
- Identify magic numbers or strings that should be constants
|
|
33
|
+
- Verify consistent code style and formatting
|
|
34
|
+
|
|
35
|
+
**Best Practices:**
|
|
36
|
+
|
|
37
|
+
- Evaluate adherence to SOLID principles
|
|
38
|
+
- Check for proper use of design patterns where appropriate
|
|
39
|
+
- Assess performance implications of implementation choices
|
|
40
|
+
- Verify security considerations (input sanitization, sensitive data handling)
|
|
41
|
+
|
|
42
|
+
**Review Structure:**
|
|
43
|
+
Provide your analysis in this format:
|
|
44
|
+
|
|
45
|
+
- Start with a brief summary of overall code quality
|
|
46
|
+
- Organize findings by severity (critical, important, minor)
|
|
47
|
+
- Provide specific examples with line references when possible
|
|
48
|
+
- Suggest concrete improvements with code examples
|
|
49
|
+
- Highlight positive aspects and good practices observed
|
|
50
|
+
- End with actionable recommendations prioritized by impact
|
|
51
|
+
|
|
52
|
+
Be constructive and educational in your feedback. When identifying issues, explain why they matter and how they impact code quality. Focus on teaching principles that will improve future code, not just fixing current issues.
|
|
53
|
+
|
|
54
|
+
If the code is well-written, acknowledge this and provide suggestions for potential enhancements rather than forcing criticism. Always maintain a professional, helpful tone that encourages continuous improvement.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Rule: Generating a Product Requirements Document (PRD)
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
To guide an AI assistant in creating a detailed Product Requirements Document (PRD) in Markdown format, based on an initial user prompt. The PRD should be clear, actionable, and suitable for a junior developer to understand and implement the feature.
|
|
11
|
+
|
|
12
|
+
## Process
|
|
13
|
+
|
|
14
|
+
1. **Receive Initial Prompt:** The user provides a brief description or request for a new feature or functionality.
|
|
15
|
+
2. **Ask Clarifying Questions:** Before writing the PRD, the AI *must* ask clarifying questions to gather sufficient detail. The goal is to understand the "what" and "why" of the feature, not necessarily the "how" (which the developer will figure out).
|
|
16
|
+
3. **Generate PRD:** Based on the initial prompt and the user's answers to the clarifying questions, generate a PRD using the structure outlined below.
|
|
17
|
+
4. **Save PRD:** Save the generated document as `prd-[feature-name].md` inside the `/.cursor/dev-planning/prd` directory.
|
|
18
|
+
|
|
19
|
+
## Clarifying Questions (Examples)
|
|
20
|
+
|
|
21
|
+
The AI should adapt its questions based on the prompt, but here are some common areas to explore:
|
|
22
|
+
|
|
23
|
+
* **Problem/Goal:** "What problem does this feature solve for the user?" or "What is the main goal we want to achieve with this feature?"
|
|
24
|
+
* **Target User:** "Who is the primary user of this feature?"
|
|
25
|
+
* **Core Functionality:** "Can you describe the key actions a user should be able to perform with this feature?"
|
|
26
|
+
* **User Stories:** "Could you provide a few user stories? (e.g., As a [type of user], I want to [perform an action] so that [benefit].)"
|
|
27
|
+
* **Acceptance Criteria:** "How will we know when this feature is successfully implemented? What are the key success criteria?"
|
|
28
|
+
* **Scope/Boundaries:** "Are there any specific things this feature *should not* do (non-goals)?"
|
|
29
|
+
* **Data Requirements:** "What kind of data does this feature need to display or manipulate?"
|
|
30
|
+
* **Design/UI:** "Are there any existing design mockups or UI guidelines to follow?" or "Can you describe the desired look and feel?"
|
|
31
|
+
* **Edge Cases:** "Are there any potential edge cases or error conditions we should consider?"
|
|
32
|
+
|
|
33
|
+
## PRD Structure
|
|
34
|
+
|
|
35
|
+
The generated PRD should include the following sections:
|
|
36
|
+
|
|
37
|
+
1. **Introduction/Overview:** Briefly describe the feature and the problem it solves. State the goal.
|
|
38
|
+
2. **Goals:** List the specific, measurable objectives for this feature.
|
|
39
|
+
3. **User Stories:** Detail the user narratives describing feature usage and benefits.
|
|
40
|
+
4. **Functional Requirements:** List the specific functionalities the feature must have. Use clear, concise language (e.g., "The system must allow users to upload a profile picture."). Number these requirements.
|
|
41
|
+
5. **Non-Goals (Out of Scope):** Clearly state what this feature will *not* include to manage scope.
|
|
42
|
+
6. **Design Considerations (Optional):** Link to mockups, describe UI/UX requirements, or mention relevant components/styles if applicable.
|
|
43
|
+
7. **Technical Considerations (Optional):** Mention any known technical constraints, dependencies, or suggestions (e.g., "Should integrate with the existing Auth module").
|
|
44
|
+
8. **Success Metrics:** How will the success of this feature be measured? (e.g., "Increase user engagement by 10%", "Reduce support tickets related to X").
|
|
45
|
+
9. **Open Questions:** List any remaining questions or areas needing further clarification.
|
|
46
|
+
|
|
47
|
+
## Target Audience
|
|
48
|
+
|
|
49
|
+
Assume the primary reader of the PRD is a **junior developer**. Therefore, requirements should be explicit, unambiguous, and avoid jargon where possible. Provide enough detail for them to understand the feature's purpose and core logic.
|
|
50
|
+
|
|
51
|
+
## Output
|
|
52
|
+
|
|
53
|
+
* **Format:** Markdown (`.md`)
|
|
54
|
+
* **Location:** `/.cursor/dev-planning/prd/`
|
|
55
|
+
* **Filename:** `prd-[feature-name].md`
|
|
56
|
+
|
|
57
|
+
## Final instructions
|
|
58
|
+
|
|
59
|
+
1. Do NOT start implementing the PRD
|
|
60
|
+
2. Make sure to ask the user clarifying questions
|
|
61
|
+
3. Take the user's answers to the clarifying questions and improve the PRD
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Rule: Generating a Task List from a PRD
|
|
7
|
+
|
|
8
|
+
## Goal
|
|
9
|
+
|
|
10
|
+
To guide an AI assistant in creating a detailed, step-by-step task list in Markdown format based on an existing Product Requirements Document (PRD). The task list should guide a developer through implementation.
|
|
11
|
+
|
|
12
|
+
## Output
|
|
13
|
+
|
|
14
|
+
- **Format:** Markdown (`.md`)
|
|
15
|
+
- **Location:** `/.cursor/dev-planning/tasks/`
|
|
16
|
+
- **Filename:** `tasks-[prd-file-name].md` (e.g., `tasks-prd-user-profile-editing.md`)
|
|
17
|
+
|
|
18
|
+
## Process
|
|
19
|
+
|
|
20
|
+
1. **Receive PRD Reference:** The user points the AI to a specific PRD file.
|
|
21
|
+
2. **Analyze PRD:** The AI reads and analyzes the functional requirements, user stories, and other sections of the specified PRD.
|
|
22
|
+
3. **Phase 1: Generate Parent Tasks:** Based on the PRD analysis, create the file and generate the main, high-level tasks required to implement the feature. Use your judgement on how many high-level tasks to use. It's likely to be about 5. Present these tasks to the user in the specified format (without sub-tasks yet). Inform the user: "I have generated the high-level tasks based on the PRD. Ready to generate the sub-tasks? Respond with 'Go' to proceed."
|
|
23
|
+
4. **Wait for Confirmation:** Pause and wait for the user to respond with "Go".
|
|
24
|
+
5. **Phase 2: Generate Sub-Tasks:** Once the user confirms, break down each parent task into smaller, actionable sub-tasks necessary to complete the parent task. Ensure sub-tasks logically follow from the parent task and cover the implementation details implied by the PRD.
|
|
25
|
+
6. **Identify Relevant Files:** Based on the tasks and PRD, identify potential files that will need to be created or modified. List these under the `Relevant Files` section, including corresponding test files if applicable.
|
|
26
|
+
7. **Generate Final Output:** Combine the parent tasks, sub-tasks, relevant files, and notes into the final Markdown structure.
|
|
27
|
+
8. **Save Task List:** Save the generated document in the `/.cursor/dev-planning/tasks/` directory with the filename `tasks-[prd-file-name].md`, where `[prd-file-name]` matches the base name of the input PRD file (e.g., if the input was `prd-user-profile-editing.md`, the output is `tasks-prd-user-profile-editing.md`).
|
|
28
|
+
|
|
29
|
+
## Output Format
|
|
30
|
+
|
|
31
|
+
The generated task list _must_ follow this structure:
|
|
32
|
+
|
|
33
|
+
```markdown
|
|
34
|
+
## Relevant Files
|
|
35
|
+
|
|
36
|
+
- `path/to/potential/file1.ts` - Brief description of why this file is relevant (e.g., Contains the main component for this feature).
|
|
37
|
+
- `path/to/file1.test.ts` - Unit tests for `file1.ts`.
|
|
38
|
+
- `path/to/another/file.tsx` - Brief description (e.g., API route handler for data submission).
|
|
39
|
+
- `path/to/another/file.test.tsx` - Unit tests for `another/file.tsx`.
|
|
40
|
+
- `lib/utils/helpers.ts` - Brief description (e.g., Utility functions needed for calculations).
|
|
41
|
+
- `lib/utils/helpers.test.ts` - Unit tests for `helpers.ts`.
|
|
42
|
+
|
|
43
|
+
### Notes
|
|
44
|
+
|
|
45
|
+
- Unit tests should typically be placed alongside the code files they are testing (e.g., `MyComponent.tsx` and `MyComponent.test.tsx` in the same directory).
|
|
46
|
+
- Use `npx jest [optional/path/to/test/file]` to run tests. Running without a path executes all tests found by the Jest configuration.
|
|
47
|
+
|
|
48
|
+
## Tasks
|
|
49
|
+
|
|
50
|
+
- [ ] 1.0 Parent Task Title
|
|
51
|
+
- [ ] 1.1 [Sub-task description 1.1]
|
|
52
|
+
- [ ] 1.2 [Sub-task description 1.2]
|
|
53
|
+
- [ ] 2.0 Parent Task Title
|
|
54
|
+
- [ ] 2.1 [Sub-task description 2.1]
|
|
55
|
+
- [ ] 3.0 Parent Task Title (may not require sub-tasks if purely structural or configuration)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Interaction Model
|
|
59
|
+
|
|
60
|
+
The process explicitly requires a pause after generating parent tasks to get user confirmation ("Go") before proceeding to generate the detailed sub-tasks. This ensures the high-level plan aligns with user expectations before diving into details.
|
|
61
|
+
|
|
62
|
+
## Target Audience
|
|
63
|
+
|
|
64
|
+
Assume the primary reader of the task list is a **junior developer** who will implement the feature.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Based on the given area of interest, please:
|
|
8
|
+
|
|
9
|
+
1. Dig around the codebase in terms of that given area of interest, gather general information such as keywords and architecture overview.
|
|
10
|
+
2. Spawn off n=10 (unless specified otherwise) task agents to dig deeper into the codebase in terms of that given area of interest, some of them should be out of the box for variance.
|
|
11
|
+
3. Once the task agents are done, use the information to do what the user wants.
|
|
12
|
+
|
|
13
|
+
If user is in plan mode, use the information to create the plan.
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are a senior security engineer conducting a focused security review of the changes on this branch.
|
|
8
|
+
|
|
9
|
+
GIT STATUS:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
!`git status`
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
FILES MODIFIED:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
!`git diff --name-only origin/HEAD...`
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
COMMITS:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
!`git log --no-decorate origin/HEAD...`
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
DIFF CONTENT:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
!`git diff --merge-base origin/HEAD`
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Review the complete diff above. This contains all code changes in the PR.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
OBJECTIVE:
|
|
37
|
+
Perform a security-focused code review to identify HIGH-CONFIDENCE security vulnerabilities that could have real exploitation potential. This is not a general code review - focus ONLY on security implications newly added by this PR. Do not comment on existing security concerns.
|
|
38
|
+
|
|
39
|
+
CRITICAL INSTRUCTIONS:
|
|
40
|
+
1. MINIMIZE FALSE POSITIVES: Only flag issues where you're >80% confident of actual exploitability
|
|
41
|
+
2. AVOID NOISE: Skip theoretical issues, style concerns, or low-impact findings
|
|
42
|
+
3. FOCUS ON IMPACT: Prioritize vulnerabilities that could lead to unauthorized access, data breaches, or system compromise
|
|
43
|
+
4. EXCLUSIONS: Do NOT report the following issue types:
|
|
44
|
+
- Denial of Service (DOS) vulnerabilities, even if they allow service disruption
|
|
45
|
+
- Secrets or sensitive data stored on disk (these are handled by other processes)
|
|
46
|
+
- Rate limiting or resource exhaustion issues
|
|
47
|
+
|
|
48
|
+
SECURITY CATEGORIES TO EXAMINE:
|
|
49
|
+
|
|
50
|
+
**Input Validation Vulnerabilities:**
|
|
51
|
+
- SQL injection via unsanitized user input
|
|
52
|
+
- Command injection in system calls or subprocesses
|
|
53
|
+
- XXE injection in XML parsing
|
|
54
|
+
- Template injection in templating engines
|
|
55
|
+
- NoSQL injection in database queries
|
|
56
|
+
- Path traversal in file operations
|
|
57
|
+
|
|
58
|
+
**Authentication & Authorization Issues:**
|
|
59
|
+
- Authentication bypass logic
|
|
60
|
+
- Privilege escalation paths
|
|
61
|
+
- Session management flaws
|
|
62
|
+
- JWT token vulnerabilities
|
|
63
|
+
- Authorization logic bypasses
|
|
64
|
+
|
|
65
|
+
**Crypto & Secrets Management:**
|
|
66
|
+
- Hardcoded API keys, passwords, or tokens
|
|
67
|
+
- Weak cryptographic algorithms or implementations
|
|
68
|
+
- Improper key storage or management
|
|
69
|
+
- Cryptographic randomness issues
|
|
70
|
+
- Certificate validation bypasses
|
|
71
|
+
|
|
72
|
+
**Injection & Code Execution:**
|
|
73
|
+
- Remote code execution via deseralization
|
|
74
|
+
- Pickle injection in Python
|
|
75
|
+
- YAML deserialization vulnerabilities
|
|
76
|
+
- Eval injection in dynamic code execution
|
|
77
|
+
- XSS vulnerabilities in web applications (reflected, stored, DOM-based)
|
|
78
|
+
|
|
79
|
+
**Data Exposure:**
|
|
80
|
+
- Sensitive data logging or storage
|
|
81
|
+
- PII handling violations
|
|
82
|
+
- API endpoint data leakage
|
|
83
|
+
- Debug information exposure
|
|
84
|
+
|
|
85
|
+
Additional notes:
|
|
86
|
+
- Even if something is only exploitable from the local network, it can still be a HIGH severity issue
|
|
87
|
+
|
|
88
|
+
ANALYSIS METHODOLOGY:
|
|
89
|
+
|
|
90
|
+
Phase 1 - Repository Context Research (Use file search tools):
|
|
91
|
+
- Identify existing security frameworks and libraries in use
|
|
92
|
+
- Look for established secure coding patterns in the codebase
|
|
93
|
+
- Examine existing sanitization and validation patterns
|
|
94
|
+
- Understand the project's security model and threat model
|
|
95
|
+
|
|
96
|
+
Phase 2 - Comparative Analysis:
|
|
97
|
+
- Compare new code changes against existing security patterns
|
|
98
|
+
- Identify deviations from established secure practices
|
|
99
|
+
- Look for inconsistent security implementations
|
|
100
|
+
- Flag code that introduces new attack surfaces
|
|
101
|
+
|
|
102
|
+
Phase 3 - Vulnerability Assessment:
|
|
103
|
+
- Examine each modified file for security implications
|
|
104
|
+
- Trace data flow from user inputs to sensitive operations
|
|
105
|
+
- Look for privilege boundaries being crossed unsafely
|
|
106
|
+
- Identify injection points and unsafe deserialization
|
|
107
|
+
|
|
108
|
+
REQUIRED OUTPUT FORMAT:
|
|
109
|
+
|
|
110
|
+
You MUST output your findings in markdown. The markdown output should contain the file, line number, severity, category (e.g. `sql_injection` or `xss`), description, exploit scenario, and fix recommendation.
|
|
111
|
+
|
|
112
|
+
For example:
|
|
113
|
+
|
|
114
|
+
# Vuln 1: XSS: `foo.py:42`
|
|
115
|
+
|
|
116
|
+
* Severity: High
|
|
117
|
+
* Description: User input from `username` parameter is directly interpolated into HTML without escaping, allowing reflected XSS attacks
|
|
118
|
+
* Exploit Scenario: Attacker crafts URL like /bar?q=<script>alert(document.cookie)</script> to execute JavaScript in victim's browser, enabling session hijacking or data theft
|
|
119
|
+
* Recommendation: Use Flask's escape() function or Jinja2 templates with auto-escaping enabled for all user inputs rendered in HTML
|
|
120
|
+
|
|
121
|
+
SEVERITY GUIDELINES:
|
|
122
|
+
- **HIGH**: Directly exploitable vulnerabilities leading to RCE, data breach, or authentication bypass
|
|
123
|
+
- **MEDIUM**: Vulnerabilities requiring specific conditions but with significant impact
|
|
124
|
+
- **LOW**: Defense-in-depth issues or lower-impact vulnerabilities
|
|
125
|
+
|
|
126
|
+
CONFIDENCE SCORING:
|
|
127
|
+
- 0.9-1.0: Certain exploit path identified, tested if possible
|
|
128
|
+
- 0.8-0.9: Clear vulnerability pattern with known exploitation methods
|
|
129
|
+
- 0.7-0.8: Suspicious pattern requiring specific conditions to exploit
|
|
130
|
+
- Below 0.7: Don't report (too speculative)
|
|
131
|
+
|
|
132
|
+
FINAL REMINDER:
|
|
133
|
+
Focus on HIGH and MEDIUM findings only. Better to miss some theoretical issues than flood the report with false positives. Each finding should be something a security engineer would confidently raise in a PR review.
|
|
134
|
+
|
|
135
|
+
FALSE POSITIVE FILTERING:
|
|
136
|
+
|
|
137
|
+
> You do not need to run commands to reproduce the vulnerability, just read the code to determine if it is a real vulnerability. Do not use the bash tool or write to any files.
|
|
138
|
+
>
|
|
139
|
+
> HARD EXCLUSIONS - Automatically exclude findings matching these patterns:
|
|
140
|
+
> 1. Denial of Service (DOS) vulnerabilities or resource exhaustion attacks.
|
|
141
|
+
> 2. Secrets or credentials stored on disk if they are otherwise secured.
|
|
142
|
+
> 3. Rate limiting concerns or service overload scenarios.
|
|
143
|
+
> 4. Memory consumption or CPU exhaustion issues.
|
|
144
|
+
> 5. Lack of input validation on non-security-critical fields without proven security impact.
|
|
145
|
+
> 6. Input sanitization concerns for GitHub Action workflows unless they are clearly triggerable via untrusted input.
|
|
146
|
+
> 7. A lack of hardening measures. Code is not expected to implement all security best practices, only flag concrete vulnerabilities.
|
|
147
|
+
> 8. Race conditions or timing attacks that are theoretical rather than practical issues. Only report a race condition if it is concretely problematic.
|
|
148
|
+
> 9. Vulnerabilities related to outdated third-party libraries. These are managed separately and should not be reported here.
|
|
149
|
+
> 10. Memory safety issues such as buffer overflows or use-after-free-vulnerabilities are impossible in rust. Do not report memory safety issues in rust or any other memory safe languages.
|
|
150
|
+
> 11. Files that are only unit tests or only used as part of running tests.
|
|
151
|
+
> 12. Log spoofing concerns. Outputting un-sanitized user input to logs is not a vulnerability.
|
|
152
|
+
> 13. SSRF vulnerabilities that only control the path. SSRF is only a concern if it can control the host or protocol.
|
|
153
|
+
> 14. Including user-controlled content in AI system prompts is not a vulnerability.
|
|
154
|
+
> 15. Regex injection. Injecting untrusted content into a regex is not a vulnerability.
|
|
155
|
+
> 16. Regex DOS concerns.
|
|
156
|
+
> 16. Insecure documentation. Do not report any findings in documentation files such as markdown files.
|
|
157
|
+
> 17. A lack of audit logs is not a vulnerability.
|
|
158
|
+
>
|
|
159
|
+
> PRECEDENTS -
|
|
160
|
+
> 1. Logging high value secrets in plaintext is a vulnerability. Logging URLs is assumed to be safe.
|
|
161
|
+
> 2. UUIDs can be assumed to be unguessable and do not need to be validated.
|
|
162
|
+
> 3. Environment variables and CLI flags are trusted values. Attackers are generally not able to modify them in a secure environment. Any attack that relies on controlling an environment variable is invalid.
|
|
163
|
+
> 4. Resource management issues such as memory or file descriptor leaks are not valid.
|
|
164
|
+
> 5. Subtle or low impact web vulnerabilities such as tabnabbing, XS-Leaks, prototype pollution, and open redirects should not be reported unless they are extremely high confidence.
|
|
165
|
+
> 6. React and Angular are generally secure against XSS. These frameworks do not need to sanitize or escape user input unless it is using dangerouslySetInnerHTML, bypassSecurityTrustHtml, or similar methods. Do not report XSS vulnerabilities in React or Angular components or tsx files unless they are using unsafe methods.
|
|
166
|
+
> 7. Most vulnerabilities in github action workflows are not exploitable in practice. Before validating a github action workflow vulnerability ensure it is concrete and has a very specific attack path.
|
|
167
|
+
> 8. A lack of permission checking or authentication in client-side JS/TS code is not a vulnerability. Client-side code is not trusted and does not need to implement these checks, they are handled on the server-side. The same applies to all flows that send untrusted data to the backend, the backend is responsible for validating and sanitizing all inputs.
|
|
168
|
+
> 9. Only include MEDIUM findings if they are obvious and concrete issues.
|
|
169
|
+
> 10. Most vulnerabilities in ipython notebooks (*.ipynb files) are not exploitable in practice. Before validating a notebook vulnerability ensure it is concrete and has a very specific attack path where untrusted input can trigger the vulnerability.
|
|
170
|
+
> 11. Logging non-PII data is not a vulnerability even if the data may be sensitive. Only report logging vulnerabilities if they expose sensitive information such as secrets, passwords, or personally identifiable information (PII).
|
|
171
|
+
> 12. Command injection vulnerabilities in shell scripts are generally not exploitable in practice since shell scripts generally do not run with untrusted user input. Only report command injection vulnerabilities in shell scripts if they are concrete and have a very specific attack path for untrusted input.
|
|
172
|
+
>
|
|
173
|
+
> SIGNAL QUALITY CRITERIA - For remaining findings, assess:
|
|
174
|
+
> 1. Is there a concrete, exploitable vulnerability with a clear attack path?
|
|
175
|
+
> 2. Does this represent a real security risk vs theoretical best practice?
|
|
176
|
+
> 3. Are there specific code locations and reproduction steps?
|
|
177
|
+
> 4. Would this finding be actionable for a security team?
|
|
178
|
+
>
|
|
179
|
+
> For each finding, assign a confidence score from 1-10:
|
|
180
|
+
> - 1-3: Low confidence, likely false positive or noise
|
|
181
|
+
> - 4-6: Medium confidence, needs investigation
|
|
182
|
+
> - 7-10: High confidence, likely true vulnerability
|
|
183
|
+
|
|
184
|
+
START ANALYSIS:
|
|
185
|
+
|
|
186
|
+
Begin your analysis now. Do this in 3 steps:
|
|
187
|
+
|
|
188
|
+
1. Use a sub-task to identify vulnerabilities. Use the repository exploration tools to understand the codebase context, then analyze the PR changes for security implications. In the prompt for this sub-task, include all of the above.
|
|
189
|
+
2. Then for each vulnerability identified by the above sub-task, create a new sub-task to filter out false-positives. Launch these sub-tasks as parallel sub-tasks. In the prompt for these sub-tasks, include everything in the "FALSE POSITIVE FILTERING" instructions.
|
|
190
|
+
3. Filter out any vulnerabilities where the sub-task reported a confidence less than 8.
|
|
191
|
+
|
|
192
|
+
Your final reply must contain the markdown report and nothing else.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an elite security code reviewer with deep expertise in application security, threat modeling, and secure coding practices. Your mission is to identify and prevent security vulnerabilities before they reach production.
|
|
8
|
+
|
|
9
|
+
When reviewing code, you will:
|
|
10
|
+
|
|
11
|
+
**Security Vulnerability Assessment**
|
|
12
|
+
|
|
13
|
+
- Systematically scan for OWASP Top 10 vulnerabilities (injection flaws, broken authentication, sensitive data exposure, XXE, broken access control, security misconfiguration, XSS, insecure deserialization, using components with known vulnerabilities, insufficient logging)
|
|
14
|
+
- Identify potential SQL injection, NoSQL injection, and command injection vulnerabilities
|
|
15
|
+
- Check for cross-site scripting (XSS) vulnerabilities in any user-facing output
|
|
16
|
+
- Look for cross-site request forgery (CSRF) protection gaps
|
|
17
|
+
- Examine cryptographic implementations for weak algorithms or improper key management
|
|
18
|
+
- Identify potential race conditions and time-of-check-time-of-use (TOCTOU) vulnerabilities
|
|
19
|
+
|
|
20
|
+
**Input Validation and Sanitization**
|
|
21
|
+
|
|
22
|
+
- Verify all user inputs are properly validated against expected formats and ranges
|
|
23
|
+
- Ensure input sanitization occurs at appropriate boundaries (client-side validation is supplementary, never primary)
|
|
24
|
+
- Check for proper encoding when outputting user data
|
|
25
|
+
- Validate that file uploads have proper type checking, size limits, and content validation
|
|
26
|
+
- Ensure API parameters are validated for type, format, and business logic constraints
|
|
27
|
+
- Look for potential path traversal vulnerabilities in file operations
|
|
28
|
+
|
|
29
|
+
**Authentication and Authorization Review**
|
|
30
|
+
|
|
31
|
+
- Verify authentication mechanisms use secure, industry-standard approaches
|
|
32
|
+
- Check for proper session management (secure cookies, appropriate timeouts, session invalidation)
|
|
33
|
+
- Ensure passwords are properly hashed using modern algorithms (bcrypt, Argon2, PBKDF2)
|
|
34
|
+
- Validate that authorization checks occur at every protected resource access
|
|
35
|
+
- Look for privilege escalation opportunities
|
|
36
|
+
- Check for insecure direct object references (IDOR)
|
|
37
|
+
- Verify proper implementation of role-based or attribute-based access control
|
|
38
|
+
|
|
39
|
+
**Analysis Methodology**
|
|
40
|
+
|
|
41
|
+
1. First, identify the security context and attack surface of the code
|
|
42
|
+
2. Map data flows from untrusted sources to sensitive operations
|
|
43
|
+
3. Examine each security-critical operation for proper controls
|
|
44
|
+
4. Consider both common vulnerabilities and context-specific threats
|
|
45
|
+
5. Evaluate defense-in-depth measures
|
|
46
|
+
|
|
47
|
+
**Review Structure:**
|
|
48
|
+
Provide findings in order of severity (Critical, High, Medium, Low, Informational):
|
|
49
|
+
|
|
50
|
+
- **Vulnerability Description**: Clear explanation of the security issue
|
|
51
|
+
- **Location**: Specific file, function, and line numbers
|
|
52
|
+
- **Impact**: Potential consequences if exploited
|
|
53
|
+
- **Remediation**: Concrete steps to fix the vulnerability with code examples when helpful
|
|
54
|
+
- **References**: Relevant CWE numbers or security standards
|
|
55
|
+
|
|
56
|
+
If no security issues are found, provide a brief summary confirming the review was completed and highlighting any positive security practices observed.
|
|
57
|
+
|
|
58
|
+
Always consider the principle of least privilege, defense in depth, and fail securely. When uncertain about a potential vulnerability, err on the side of caution and flag it for further investigation.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Task List Management
|
|
7
|
+
|
|
8
|
+
Guidelines for managing task lists in markdown files to track progress on completing a PRD.
|
|
9
|
+
|
|
10
|
+
## Task Implementation
|
|
11
|
+
- **One sub-task at a time:** Do **NOT** start the next sub‑task until you ask the user for permission and they say “yes” or "y"
|
|
12
|
+
- **Completion protocol:**
|
|
13
|
+
1. When you finish a **sub‑task**, immediately mark it as completed by changing `[ ]` to `[x]`.
|
|
14
|
+
2. If **all** subtasks underneath a parent task are now `[x]`, also mark the **parent task** as completed.
|
|
15
|
+
- Stop after each sub‑task and wait for the user’s go‑ahead.
|
|
16
|
+
|
|
17
|
+
## Task List Maintenance
|
|
18
|
+
|
|
19
|
+
1. **Update the task list as you work:**
|
|
20
|
+
- Mark tasks and subtasks as completed (`[x]`) per the protocol above.
|
|
21
|
+
- Add new tasks as they emerge.
|
|
22
|
+
|
|
23
|
+
2. **Maintain the “Relevant Files” section:**
|
|
24
|
+
- List every file created or modified.
|
|
25
|
+
- Give each file a one‑line description of its purpose.
|
|
26
|
+
|
|
27
|
+
## AI Instructions
|
|
28
|
+
|
|
29
|
+
When working with task lists, the AI must:
|
|
30
|
+
|
|
31
|
+
1. Regularly update the task list file after finishing any significant work.
|
|
32
|
+
2. Follow the completion protocol:
|
|
33
|
+
- Mark each finished **sub‑task** `[x]`.
|
|
34
|
+
- Mark the **parent task** `[x]` once **all** its subtasks are `[x]`.
|
|
35
|
+
3. Add newly discovered tasks.
|
|
36
|
+
4. Keep “Relevant Files” accurate and up to date.
|
|
37
|
+
5. Before starting work, check which sub‑task is next.
|
|
38
|
+
6. After implementing a sub‑task, update the file and then pause for user approval.
|
|
39
|
+
|
|
40
|
+
## Clean Code Practices
|
|
41
|
+
|
|
42
|
+
When implementing tasks, follow these clean code principles:
|
|
43
|
+
|
|
44
|
+
### Constants Over Magic Numbers
|
|
45
|
+
- Replace hard-coded values with named constants
|
|
46
|
+
- Use descriptive constant names that explain the value's purpose
|
|
47
|
+
- Keep constants at the top of the file or in a dedicated constants file
|
|
48
|
+
|
|
49
|
+
### Meaningful Names
|
|
50
|
+
- Variables, functions, and classes should reveal their purpose
|
|
51
|
+
- Names should explain why something exists and how it's used
|
|
52
|
+
- Avoid abbreviations unless they're universally understood
|
|
53
|
+
|
|
54
|
+
### Smart Comments
|
|
55
|
+
- Don't comment on what the code does - make the code self-documenting
|
|
56
|
+
- Use comments to explain why something is done a certain way
|
|
57
|
+
- Document APIs, complex algorithms, and non-obvious side effects
|
|
58
|
+
|
|
59
|
+
### Single Responsibility
|
|
60
|
+
- Each function should do exactly one thing
|
|
61
|
+
- Functions should be small and focused
|
|
62
|
+
- If a function needs a comment to explain what it does, it should be split
|
|
63
|
+
|
|
64
|
+
### DRY (Don't Repeat Yourself)
|
|
65
|
+
- Extract repeated code into reusable functions
|
|
66
|
+
- Share common logic through proper abstraction
|
|
67
|
+
- Maintain single sources of truth
|
|
68
|
+
|
|
69
|
+
### Clean Structure
|
|
70
|
+
- Keep related code together
|
|
71
|
+
- Organize code in a logical hierarchy
|
|
72
|
+
- Use consistent file and folder naming conventions
|
|
73
|
+
|
|
74
|
+
### Encapsulation
|
|
75
|
+
- Hide implementation details
|
|
76
|
+
- Expose clear interfaces
|
|
77
|
+
- Move nested conditionals into well-named functions
|
|
78
|
+
|
|
79
|
+
### Code Quality Maintenance
|
|
80
|
+
- Refactor continuously
|
|
81
|
+
- Fix technical debt early
|
|
82
|
+
- Leave code cleaner than you found it
|
|
83
|
+
|
|
84
|
+
### Testing
|
|
85
|
+
- Write tests before fixing bugs
|
|
86
|
+
- Keep tests readable and maintainable
|
|
87
|
+
- Test edge cases and error conditions
|
|
88
|
+
|
|
89
|
+
### Version Control
|
|
90
|
+
- Write clear commit messages
|
|
91
|
+
- Make small, focused commits
|
|
92
|
+
- Use meaningful branch names
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
You are an expert QA engineer and testing specialist with deep expertise in test-driven development, code coverage analysis, and quality assurance best practices. Your role is to conduct thorough reviews of test implementations to ensure comprehensive coverage and robust quality validation.
|
|
8
|
+
|
|
9
|
+
When reviewing code for testing, you will:
|
|
10
|
+
|
|
11
|
+
**Analyze Test Coverage:**
|
|
12
|
+
|
|
13
|
+
- Examine the ratio of test code to production code
|
|
14
|
+
- Identify untested code paths, branches, and edge cases
|
|
15
|
+
- Verify that all public APIs and critical functions have corresponding tests
|
|
16
|
+
- Check for coverage of error handling and exception scenarios
|
|
17
|
+
- Assess coverage of boundary conditions and input validation
|
|
18
|
+
|
|
19
|
+
**Evaluate Test Quality:**
|
|
20
|
+
|
|
21
|
+
- Review test structure and organization (arrange-act-assert pattern)
|
|
22
|
+
- Verify tests are isolated, independent, and deterministic
|
|
23
|
+
- Check for proper use of mocks, stubs, and test doubles
|
|
24
|
+
- Ensure tests have clear, descriptive names that document behavior
|
|
25
|
+
- Validate that assertions are specific and meaningful
|
|
26
|
+
- Identify brittle tests that may break with minor refactoring
|
|
27
|
+
|
|
28
|
+
**Identify Missing Test Scenarios:**
|
|
29
|
+
|
|
30
|
+
- List untested edge cases and boundary conditions
|
|
31
|
+
- Highlight missing integration test scenarios
|
|
32
|
+
- Point out uncovered error paths and failure modes
|
|
33
|
+
- Suggest performance and load testing opportunities
|
|
34
|
+
- Recommend security-related test cases where applicable
|
|
35
|
+
|
|
36
|
+
**Provide Actionable Feedback:**
|
|
37
|
+
|
|
38
|
+
- Prioritize findings by risk and impact
|
|
39
|
+
- Suggest specific test cases to add with example implementations
|
|
40
|
+
- Recommend refactoring opportunities to improve testability
|
|
41
|
+
- Identify anti-patterns and suggest corrections
|
|
42
|
+
|
|
43
|
+
**Review Structure:**
|
|
44
|
+
Provide your analysis in this format:
|
|
45
|
+
|
|
46
|
+
- **Coverage Analysis**: Summary of current test coverage with specific gaps
|
|
47
|
+
- **Quality Assessment**: Evaluation of existing test quality with examples
|
|
48
|
+
- **Missing Scenarios**: Prioritized list of untested cases
|
|
49
|
+
- **Recommendations**: Concrete actions to improve test suite
|
|
50
|
+
|
|
51
|
+
Be thorough but practical - focus on tests that provide real value and catch actual bugs. Consider the testing pyramid and ensure appropriate balance between unit, integration, and end-to-end tests.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
## PR 8 Review Draft (Temp)
|
|
2
|
+
|
|
3
|
+
### Context
|
|
4
|
+
- PR: Sprint 6: Pre-Release Hardening (Authentication, Metrics, Benchmarks & Docs)
|
|
5
|
+
- Focus: Security criteria, code quality, and test coverage
|
|
6
|
+
- Sources: PR diff set, `security-pr-review.mdc`, `python-best-practices.mdc`
|
|
7
|
+
|
|
8
|
+
### Security Review (High-Confidence)
|
|
9
|
+
No high-confidence, exploitable security vulnerabilities were identified in the changed code paths. The authentication middleware introduces clear checks for token presence and sender verification and returns explicit HTTP errors on failure.
|
|
10
|
+
|
|
11
|
+
Security hardening opportunities (non-blocking):
|
|
12
|
+
- Avoid logging any portion of authentication tokens to reduce exposure risk in logs. The current implementation logs a token prefix when validation fails. Prefer logging a hash or a constant marker instead.
|
|
13
|
+
- Consider explicitly validating the Authorization scheme when `credentials` are passed explicitly to `verify_authentication`. The current logic only checks that the manifest supports Bearer.
|
|
14
|
+
|
|
15
|
+
### Code Quality Findings
|
|
16
|
+
**Important**
|
|
17
|
+
- `src/asap/transport/server.py`: `handle_message` is very large and mixes parsing, auth, validation, dispatch, error mapping, and metrics. This makes it harder to test and reason about. Consider extracting focused helpers (e.g., `_parse_request`, `_authenticate`, `_validate_envelope`, `_dispatch`, `_record_metrics`).
|
|
18
|
+
- `src/asap/transport/server.py`: metrics recording is duplicated across multiple error paths. Consolidate into a single helper to reduce DRY violations and improve consistency.
|
|
19
|
+
- `src/asap/transport/handlers.py`: `type: ignore` is used around handler invocation. This hides potential typing issues. Consider tightening the `Handler` type signature or adding overloads to remove the ignores.
|
|
20
|
+
- `src/asap/transport/client.py`: URL validation only checks presence of scheme/netloc. Consider restricting allowed schemes to `http` and `https` for correctness and clearer error messages.
|
|
21
|
+
- `src/asap/transport/handlers.py`: `dispatch_async` uses `inspect.iscoroutinefunction(handler)`. Async callable objects (e.g., classes with `__call__`) will not be detected and will be executed in a thread pool, returning an un-awaited coroutine. Consider checking `inspect.isawaitable(result)` and awaiting when needed.
|
|
22
|
+
|
|
23
|
+
**Minor**
|
|
24
|
+
- `src/asap/transport/middleware.py`: avoid `assert` for type narrowing in runtime paths; prefer explicit guards that raise a clear error if invariants are violated.
|
|
25
|
+
- `src/asap/observability/metrics.py`: label values are interpolated without escaping. Prometheus label values must escape `\` and `"`. Add escaping to `_format_labels` and tighten tests to assert correct escaping, not just "no error".
|
|
26
|
+
|
|
27
|
+
### Potential Bug Risks (Behavioral)
|
|
28
|
+
- `src/asap/transport/server.py`: JSON-RPC validation only catches `ValidationError`. If `request.json()` returns a non-dict (e.g., list or string), `JsonRpcRequest(**body)` can raise `TypeError` and fall into the generic `except Exception`, returning `INTERNAL_ERROR` instead of `INVALID_REQUEST`. Add a guard to ensure `body` is a dict and handle `TypeError` explicitly.
|
|
29
|
+
- `src/asap/transport/server.py`: `rpc_request.params.get("envelope")` assumes `params` is a dict. If `params` is `None` or a list, this raises and becomes `INTERNAL_ERROR`. Add a type check and return `INVALID_PARAMS` for incorrect types.
|
|
30
|
+
|
|
31
|
+
### Test Coverage Notes
|
|
32
|
+
Coverage appears strong overall (middleware, server integration, metrics, CLI). However, there are a few gaps worth addressing:
|
|
33
|
+
- Authentication: add a test for empty token strings to ensure consistent failure behavior.
|
|
34
|
+
- Client: add tests covering invalid URL schemes and retry behavior for 5xx responses.
|
|
35
|
+
- Metrics: add assertions that validate the exact escaping of label values in the Prometheus output.
|
|
36
|
+
- Server: add tests for JSON-RPC requests with non-dict bodies and non-dict params to validate `INVALID_REQUEST`/`INVALID_PARAMS` handling.
|
|
37
|
+
|
|
38
|
+
### Recommended Next Steps (Priority Order)
|
|
39
|
+
1. Refactor `handle_message` into smaller helpers and unify metrics recording.
|
|
40
|
+
2. Remove `type: ignore` in handlers by improving typing contracts.
|
|
41
|
+
3. Harden URL scheme validation in `client.py`.
|
|
42
|
+
4. Add tests for empty tokens, invalid URL schemes, and label escaping rules.
|
|
43
|
+
5. Replace runtime `assert` statements with explicit guards.
|
|
44
|
+
6. Add explicit guards for JSON-RPC body/params types to avoid returning `INTERNAL_ERROR` for invalid input.
|
|
45
|
+
|