Skip to content

Commit 3bfe099

Browse files
committed
doc : update README.md
1 parent 417d76e commit 3bfe099

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
# AI Code Tutor
55

6-
This GitHub Action uses AI to provide personalized feedback for student assignments in C/C++ and Python. It analyzes test results and code, identifying errors, suggesting optimizations, and explaining concepts clearly. Ideal for GitHub Classroom, it saves instructors time and ensures consistent, on-demand feedback.
6+
This GitHub Action uses AI to provide personalized feedback for student assignments in C/C++ and Python. It analyzes test results and code, identifying errors, suggesting optimizations, and explaining concepts clearly. Ideal for GitHub Classroom, it saves instructors time and ensures consistent, on-demand feedback with enhanced security against prompt injection attacks.
77

8-
The AI tutor processes JSON test reports from `pytest-json-report`, generated by `pytest` tests wrapping C/C++ or Python code. It detects logic errors, recommends efficient algorithms, and links to relevant documentation.
8+
The AI tutor processes JSON test reports from `pytest-json-report`, generated by `pytest` tests wrapping C/C++ or Python code. It detects logic errors, recommends efficient algorithms, and links to relevant documentation. New security features sanitize inputs and use random delimiters to prevent malicious prompt manipulation.
99

1010
## Key Features
1111
- AI-powered feedback for C/C++ and Python assignments.
@@ -14,6 +14,7 @@ The AI tutor processes JSON test reports from `pytest-json-report`, generated by
1414
- Flexible LLM selection (Claude, Gemini, Grok, Nvidia NIM, Perplexity) with Gemini fallback.
1515
- Customizable feedback language (e.g., English, Korean).
1616
- Excludes common README content to optimize API usage.
17+
- **Security Enhancements**: Sanitizes student code and READMEs to remove malicious patterns and wraps content with random delimiters to prevent prompt injection attacks.
1718

1819
## Prerequisites
1920
- **Python Dependencies**:
@@ -47,7 +48,7 @@ jobs:
4748
WORKSPACE_OUTPUT: ${{ runner.temp }}/output
4849
CONTAINER_OUTPUT: /output
4950
steps:
50-
- uses: actions/checkout@v4
51+
- uses: actions/checkout@v5
5152
- name: Set up environment
5253
run: pip install pytest==8.3.5 pytest-json-report==1.5.0 pytest-xdist==3.6.1 requests==2.32.4
5354
- name: Create output folder
@@ -61,14 +62,14 @@ jobs:
6162
ghcr.io/kangwonlee/edu-base-cpp:4e0d6d8 \
6263
/bin/sh -c "cmake . -DCMAKE_BUILD_TYPE=Debug -DSTUDENT_DIR=${{ env.CONTAINER_WORKSPACE }} && make && python3 -m pytest --json-report --json-report-indent=4 --json-report-file=${{ env.CONTAINER_OUTPUT }}/report.json test_dynamic.py"
6364
- name: AI Code Tutor
64-
uses: kangwonlee/[email protected].7
65+
uses: kangwonlee/[email protected].12
6566
if: always()
6667
with:
6768
report-files: ${{ env.WORKSPACE_OUTPUT }}/report.json
6869
student-files: ${{ env.CONTAINER_SRC }}/${{ env.C_FILENAME }}
6970
readme-path: ${{ env.CONTAINER_WORKSPACE }}/README.md
7071
explanation-in: English
71-
model: gemini
72+
model: gemini-2.5-flash
7273
INPUT_CLAUDE_API_KEY: ${{ secrets.INPUT_CLAUDE_API_KEY }}
7374
INPUT_GOOGLE_API_KEY: ${{ secrets.INPUT_GOOGLE_API_KEY }}
7475
INPUT_GROK_API_KEY: ${{ secrets.INPUT_GROK_API_KEY }}
@@ -79,12 +80,13 @@ jobs:
7980

8081
### Notes
8182
- **C/C++ Testing**: Tests can run in a Docker container with `pytest` wrapping C/C++ code (e.g., via `ctypes` for shared libraries, as in `test_dynamic.py`). Ensure JSON reports are generated.
82-
- **Model Selection**: Set `model` to prefer an LLM (e.g., `gemini`). If its key is unavailable, the action falls back to Gemini if `INPUT_GOOGLE_API_KEY` is set, or uses any one of available key.
83+
- **Model Selection**: Set `model` to prefer an LLM (e.g., `gemini-2.5-flash`). If its key is unavailable, the action falls back to Gemini if `INPUT_GOOGLE_API_KEY` is set, or uses any available key.
8384
- **Secrets**: Store API keys as repository secrets with `INPUT_` prefix (e.g., `INPUT_GOOGLE_API_KEY`) in Settings > Secrets and variables > Actions.
8485
- **README Optimization**: Exclude common README content with:
8586
- Start: ``From here is common to all assignments.``
8687
- End: ``Until here is common to all assignments.``
8788
- Use double backticks (``).
89+
- **Security**: Student code and READMEs are sanitized to remove malicious patterns (e.g., "ignore previous instructions") and wrapped with random delimiters to prevent prompt injection.
8890

8991
### Optimizing pytest for AI Feedback
9092
- Use descriptive test names (e.g., `test_sum_range_for__valid_input`).
@@ -94,11 +96,11 @@ jobs:
9496
## Inputs
9597
| Input | Description | Required | Default |
9698
|-------------------------|--------------------------------------------------|----------|-----------------|
97-
| `report-files` | Comma-separated JSON report files | Yes | `report.json` |
98-
| `student-files` | Comma-separated student code files (`.c`, `.cpp`, `.py`) | Yes | `exercise.py` |
99-
| `readme-path` | Path to assignment instructions (README.md) | No | `README.md` |
99+
| `report-files` | Comma-separated JSON report files | Yes | None |
100+
| `student-files` | Comma-separated student code files (`.c`, `.cpp`, `.py`) | Yes | None |
101+
| `readme-path` | Path to assignment instructions (README.md) | Yes | None |
100102
| `explanation-in` | Feedback language (e.g., English, Korean) | No | `English` |
101-
| `model` | Preferred LLM (e.g., `gemini`, `claude`) | No | None |
103+
| `model` | Preferred LLM (e.g., `gemini-2.5-flash`, `claude-sonnet-4-20250514`) | No | `gemini-2.5-flash` |
102104
| `INPUT_CLAUDE_API_KEY` | Claude API key | No* | None |
103105
| `INPUT_GOOGLE_API_KEY` | Google Gemini API key | No* | None |
104106
| `INPUT_GROK_API_KEY` | Grok API key | No* | None |
@@ -114,7 +116,7 @@ with:
114116
student-files: 'src/main.c,src/utils.c'
115117
readme-path: README.md
116118
explanation-in: English
117-
model: gemini
119+
model: gemini-2.5-flash
118120
INPUT_GOOGLE_API_KEY: ${{ secrets.INPUT_GOOGLE_API_KEY }}
119121
INPUT_CLAUDE_API_KEY: ${{ secrets.INPUT_CLAUDE_API_KEY }}
120122
```
@@ -126,11 +128,13 @@ with:
126128
- Primarily supports C/C++ and Python assignments via `pytest-json-report`.
127129
- Requires at least one valid API key.
128130
- C/C++ feedback relies on `pytest` tests wrapping compiled code.
131+
- Prompt injection mitigated but not eliminated; use in controlled environments.
129132

130133
## Future Enhancements
131134
- Auto-detect feedback language.
132135
- Support additional programming languages.
133136
- Add verbose mode for detailed feedback.
137+
- Enhance prompt injection defenses with advanced parsing.
134138

135139
## Troubleshooting
136140
Check GitHub Actions logs for details.
@@ -139,6 +143,7 @@ Check GitHub Actions logs for details.
139143
- **API Key Issues**: "No API keys provided" – Ensure at least one API key is set in secrets.
140144
- **Report File Issues**: "Report file not found" – Verify JSON report exists.
141145
- **Student File Issues**: "Student file not found" – Check file paths and extensions.
146+
- **Prompt Injection**: Malicious inputs are sanitized and wrapped with random delimiters, but monitor outputs for anomalies.
142147

143148
### Debugging Tips
144149
- View logs in the "AI Code Tutor" job.
@@ -149,10 +154,10 @@ Check GitHub Actions logs for details.
149154
Questions? Contact [https://github.com/kangwonlee](https://github.com/kangwonlee).
150155

151156
## License
152-
BSD 3-Clause License + Do Not Harm.
157+
BSD 3-Clause License + Do Not Harm.
153158
Copyright (c) 2024 Kangwon Lee
154159

155160
## Acknowledgements
156161
- Built using [python-github-action-template](https://github.com/cicirello/python-github-action-template) by Vincent A. Cicirello (MIT License).
157-
- Gemini 2.0 Flash and Grok 3 assisted with code and documentation.
162+
- Gemini 2.5 Flash and Grok assisted with code and documentation.
158163
- Registered as #C-2024-034203, #C-2024-035473, #C-2025-016393, and #C-2025-027967 with the Korea Copyright Commission.

0 commit comments

Comments
 (0)