test: use tempfile.gettempdir() for all bg-sync debug screenshots
The remaining SonarCloud S5443 (publicly-writable directory) findings were the hard-coded /tmp screenshot paths in revoke_background_sync_access, which became "new code" once the surrounding function was edited. Replace every /tmp literal in the file with tempfile.gettempdir() (which S5443 accepts), eliminating the findings consistently rather than per-line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
86e906b142
commit
ec667a1646
@@ -524,7 +524,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool:
|
|||||||
await revoke_button.wait_for(timeout=5000, state="visible")
|
await revoke_button.wait_for(timeout=5000, state="visible")
|
||||||
logger.info("Found 'Disable background indexing' button")
|
logger.info("Found 'Disable background indexing' button")
|
||||||
except Exception:
|
except Exception:
|
||||||
screenshot_path = f"/tmp/astrolabe_no_revoke_button_{username}.png"
|
screenshot_path = (
|
||||||
|
f"{tempfile.gettempdir()}/astrolabe_no_revoke_button_{username}.png"
|
||||||
|
)
|
||||||
await page.screenshot(path=screenshot_path)
|
await page.screenshot(path=screenshot_path)
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Could not find revoke button for {username}. Screenshot: {screenshot_path}"
|
f"Could not find revoke button for {username}. Screenshot: {screenshot_path}"
|
||||||
@@ -561,7 +563,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool:
|
|||||||
else:
|
else:
|
||||||
logger.warning("No response found for credentials/revoke endpoint!")
|
logger.warning("No response found for credentials/revoke endpoint!")
|
||||||
# Take screenshot for debugging
|
# Take screenshot for debugging
|
||||||
screenshot_path = f"/tmp/astrolabe_revoke_no_response_{username}.png"
|
screenshot_path = (
|
||||||
|
f"{tempfile.gettempdir()}/astrolabe_revoke_no_response_{username}.png"
|
||||||
|
)
|
||||||
await page.screenshot(path=screenshot_path)
|
await page.screenshot(path=screenshot_path)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -586,7 +590,9 @@ async def revoke_background_sync_access(page: Page, username: str) -> bool:
|
|||||||
try:
|
try:
|
||||||
if await page.locator("#mcp-revoke-background-button").is_visible(timeout=2000):
|
if await page.locator("#mcp-revoke-background-button").is_visible(timeout=2000):
|
||||||
logger.error("Revoke button still visible for %s after revoke!", username)
|
logger.error("Revoke button still visible for %s after revoke!", username)
|
||||||
screenshot_path = f"/tmp/astrolabe_revoke_still_enabled_{username}.png"
|
screenshot_path = (
|
||||||
|
f"{tempfile.gettempdir()}/astrolabe_revoke_still_enabled_{username}.png"
|
||||||
|
)
|
||||||
await page.screenshot(path=screenshot_path)
|
await page.screenshot(path=screenshot_path)
|
||||||
return False
|
return False
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
Reference in New Issue
Block a user