Skip to content

Commit e863e4f

Browse files
zkoppertCopilot
andcommitted
fix: enforce 1-90 day range for cooldown validation
Update validation to match Dependabot's documented constraints: cooldown days must be between 1 and 90 (inclusive). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9e385ed commit e863e4f

4 files changed

Lines changed: 56 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ npm:
227227
| `include` | List of dependency names to apply cooldown to (up to 150 items, supports `*` wildcards). |
228228
| `exclude` | List of dependency names excluded from cooldown (up to 150 items, supports `*` wildcards). |
229229
230-
At least one of the `*-days` parameters must be specified. All day values must be non-negative integers.
230+
At least one of the `*-days` parameters must be specified. All day values must be integers between 1 and 90.
231231
232232
### Example workflows
233233

dependabot_file.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
)
2525
VALID_COOLDOWN_KEYS = VALID_COOLDOWN_DAYS_KEYS | {"include", "exclude"}
2626
MAX_COOLDOWN_LIST_ITEMS = 150
27+
MIN_COOLDOWN_DAYS = 1
28+
MAX_COOLDOWN_DAYS = 90
2729

2830

2931
def validate_cooldown_config(cooldown):
@@ -51,10 +53,15 @@ def validate_cooldown_config(cooldown):
5153
value = cooldown[key]
5254
if not isinstance(value, int) or isinstance(value, bool):
5355
raise ValueError(
54-
f"Cooldown '{key}' must be a non-negative integer, got {type(value).__name__}"
56+
f"Cooldown '{key}' must be an integer between "
57+
f"{MIN_COOLDOWN_DAYS} and {MAX_COOLDOWN_DAYS}, "
58+
f"got {type(value).__name__}"
59+
)
60+
if value < MIN_COOLDOWN_DAYS or value > MAX_COOLDOWN_DAYS:
61+
raise ValueError(
62+
f"Cooldown '{key}' must be between "
63+
f"{MIN_COOLDOWN_DAYS} and {MAX_COOLDOWN_DAYS}"
5564
)
56-
if value < 0:
57-
raise ValueError(f"Cooldown '{key}' must be a non-negative integer")
5865
has_days = True
5966

6067
if not has_days:

summary.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
## 🚀 Job Summary
3+
- **Organization:** None
4+
- **Follow Up Type:** pull
5+
- **Dry Run:** False
6+
- **Enable Security Updates:** False
7+
8+
9+
10+
## 📋 Updated Repositories
11+
12+
| Repository | 🔒 Security Updates Enabled | 🔄 Follow Up Type | 🔗 Link |
13+
| --- | --- | --- | --- |
14+
15+
16+
## 🚀 Job Summary
17+
- **Organization:** None
18+
- **Follow Up Type:** pull
19+
- **Dry Run:** False
20+
- **Enable Security Updates:** False
21+
22+
23+
24+
## 📋 Updated Repositories
25+
26+
| Repository | 🔒 Security Updates Enabled | 🔄 Follow Up Type | 🔗 Link |
27+
| --- | --- | --- | --- |
28+
| github/accessibility-alt-text-bot || pull | [Link](https://github.com/github/accessibility-alt-text-bot/pull/67) |
29+

test_cooldown.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ def test_valid_with_include_exclude(self):
3434
)
3535

3636
def test_valid_zero_days(self):
37-
"""Test that zero is a valid value for days"""
38-
validate_cooldown_config({"default-days": 0})
37+
"""Test that zero is below the minimum and raises ValueError"""
38+
with self.assertRaises(ValueError):
39+
validate_cooldown_config({"default-days": 0})
40+
41+
def test_valid_boundary_min(self):
42+
"""Test that 1 day is the minimum valid value"""
43+
validate_cooldown_config({"default-days": 1})
44+
45+
def test_valid_boundary_max(self):
46+
"""Test that 90 days is the maximum valid value"""
47+
validate_cooldown_config({"default-days": 90})
3948

4049
def test_invalid_not_a_dict(self):
4150
"""Test that non-dict cooldown raises ValueError"""
@@ -52,6 +61,11 @@ def test_invalid_negative_days(self):
5261
with self.assertRaises(ValueError):
5362
validate_cooldown_config({"default-days": -1})
5463

64+
def test_invalid_days_exceed_max(self):
65+
"""Test that days above 90 raises ValueError"""
66+
with self.assertRaises(ValueError):
67+
validate_cooldown_config({"default-days": 91})
68+
5569
def test_invalid_days_not_int(self):
5670
"""Test that non-integer days raises ValueError"""
5771
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)