Skip to content

Commit 6fc7e0e

Browse files
committed
sec: pin SHA commits in workflows
1 parent a28734c commit 6fc7e0e

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717

1818
steps:
1919
- name: Checkout repository
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
2121

2222
- name: Set up Python
23-
uses: actions/setup-python@v4
23+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2424
with:
2525
python-version: '3.10'
2626

.github/workflows/security.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2121
with:
2222
python-version: "3.10"
2323

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
1818

1919
- name: Set up Python
20-
uses: actions/setup-python@v4
20+
uses: actions/setup-python@7f4fc3e22c37d6ff65e88745f38bd3157c663f7c # v4
2121
with:
2222
python-version: "3.10"
2323

src/whispr/logging.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,29 @@ def _default_log_path() -> str:
2424

2525
def _resolve_log_path() -> str:
2626
log_path = _default_log_path()
27-
log_dir = Path(log_path).parent
28-
try:
29-
log_dir.mkdir(parents=True, exist_ok=True)
27+
if _ensure_writable_log_path(log_path):
3028
return log_path
29+
30+
if platform.system() == "Darwin":
31+
fallback_dir = Path.home() / "Library" / "Logs" / "whispr"
32+
else:
33+
fallback_dir = Path.home() / ".local" / "state" / "whispr"
34+
fallback_path = str(fallback_dir / "access.log")
35+
if _ensure_writable_log_path(fallback_path):
36+
return fallback_path
37+
38+
return str(Path.cwd() / "whispr_access.log")
39+
40+
41+
def _ensure_writable_log_path(log_path: str) -> bool:
42+
log_file = Path(log_path)
43+
try:
44+
log_file.parent.mkdir(parents=True, exist_ok=True)
45+
with log_file.open("a", encoding="utf-8"):
46+
pass
47+
return True
3148
except OSError:
32-
if platform.system() == "Darwin":
33-
fallback_dir = Path.home() / "Library" / "Logs" / "whispr"
34-
else:
35-
fallback_dir = Path.home() / ".local" / "state" / "whispr"
36-
fallback_dir.mkdir(parents=True, exist_ok=True)
37-
return str(fallback_dir / "access.log")
49+
return False
3850

3951

4052
def setup_structlog() -> structlog.BoundLogger:

0 commit comments

Comments
 (0)