Skip to content

Commit cc8c903

Browse files
🛡️ Sentinel: Fix CI version and add input sanitization
- Corrected non-existent GitHub Action version for checkout in workflows. - Implemented input normalization in app.py to strip whitespace. - Added test case for whitespace-only name inputs.
1 parent 49ade1f commit cc8c903

4 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎.github/workflows/check.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- "3.13"
1515
- "3.12"
1616
steps:
17-
- uses: actions/checkout@v7
17+
- uses: actions/checkout@v4
1818
- uses: jdx/mise-action@v4
1919
with:
2020
tool_versions: |

‎.github/workflows/docs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
deploy:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v7
13+
- uses: actions/checkout@v4
1414
- uses: jdx/mise-action@v4
1515
- name: Configure Git Credentials
1616
run: |

‎project/app.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def main(name: str = "World"):
2323
Args:
2424
name: the name to be greeted
2525
"""
26+
name = name.strip() or "World"
2627
if len(name) > 100:
2728
raise UsageError("Invalid name: maximum length is 100 characters.")
2829
if not name.isprintable():

‎tests/test_app.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ def test_greet():
2626
assert "Hello Jules! 👋" in result.output
2727

2828

29+
def test_greet_whitespace():
30+
runner = CliRunner()
31+
result = runner.invoke(main, ["--name", " "])
32+
assert result.exit_code == 0
33+
assert "Hello World! 👋" in result.output
34+
35+
2936
def test_name_too_long():
3037
runner = CliRunner()
3138
result = runner.invoke(main, ["--name", "A" * 101])

0 commit comments

Comments
 (0)