Update GEMINI.md with Vim folding mandate and add test cases for set-flag-format CLI command

This commit is contained in:
venus
2026-07-17 01:53:04 -05:00
parent 82ada56655
commit cf21abe0bc
2 changed files with 30 additions and 3 deletions

View File

@@ -10,15 +10,16 @@ The primary goal is to use the context of CTF challenges (forensics, crypto, web
2. **Focus on Explanation:** Prioritize high-signal explanations of Python mechanics, libraries, and documentation.
3. **Summarization:** When directed, summarize documentation (local or web-based) to aid in understanding CTF tools and Python modules.
4. **Educational Context:** Use the existing scripts and tools in this repository (like `psk_crack.py`, `exploit.sh`, or the `tools/` directory) as examples when explaining technical concepts.
5. **Vim Folding Markers:** Wrap all classes, command groups, subcommands, and functions inside project implementation files in standard Vim/Neovim folding syntax markers (`# {{{ <name>` and `# }}}`).
## Interaction Workflow
When discussing new implementations, features, or additions:
1. **Discussion**: Discuss implementation details and potential approaches.
2. **The Pitch**: Provide a clear, technical pitch detailing the planned code modifications.
3. **Implementation Cycle**: Once the user approves the pitch:
* **Add Test Cases**: Write or update the corresponding test cases in `test_utils.py` following the SDET instructions.
* **Git Commit Current State**: Create a git commit of the current workspace state to track progress safely.
* **Update the Codebase**: Write/update the actual project implementation files as approved.
* **Add Test Cases**: Write or update the corresponding test cases in the test files (e.g. `tests/test_forensics.py`) following the SDET instructions.
* **Git Commit Current State**: Create a git commit of the current workspace state (including the new tests) *before* modifying any implementation files.
* **Update the Codebase**: Write/update the actual project implementation files as approved. Do **NOT** create a git commit after writing this implementation code. This ensures all implementation changes remain unstaged so the user can easily run `git diff` to review them.
## Python Learning Objectives
- Understanding standard library modules relevant to security (e.g., `os`, `sys`, `base64`, `hashlib`).

View File

@@ -295,3 +295,29 @@ def test_forensics_flag_detect_cli_not_found():
result = runner.invoke(forensics_group, ["flag-detect", str(test_file)])
assert result.exit_code == 0
assert "No flag patterns found" in result.output
def test_set_flag_format_cli():
"""
Verifies that 'set-flag-format' CLI command writes the pattern to config.toml.
"""
from ctf.commands import set_flag_format
from ctf.utils import load_config
runner = CliRunner()
config_file = Path("/home/venus/code/ctf/config.toml")
# Save the original config to restore later
original_config = load_config(str(config_file))
try:
result = runner.invoke(set_flag_format, ["TEST_FLAG{[a-z]+}"])
assert result.exit_code == 0
assert "Flag format set to" in result.output
# Verify it was written to config.toml
updated_config = load_config(str(config_file))
assert updated_config["Competition"]["flag_format"] == "TEST_FLAG{[a-z]+}"
finally:
# Restore original config
from ctf.utils import write_config
write_config(original_config, str(config_file))