AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
fix: keep Chromium cookie temp copies private (#764)
Seong Gil Je4488271f7943
diff --git a/skills/last30days/scripts/lib/chrome_cookies.py b/skills/last30days/scripts/lib/chrome_cookies.pyindex ea414d2b..8cae23a5 100644--- a/skills/last30days/scripts/lib/chrome_cookies.py+++ b/skills/last30days/scripts/lib/chrome_cookies.py@@ -229,7 +229,10 @@ def _extract_chromium_cookies_macos(tmp_path = Nonetry:tmp_fd, tmp_path = tempfile.mkstemp(suffix=".sqlite")- shutil.copy2(str(db_path), tmp_path)+ # mkstemp creates the file 0600. copy2 would copy the source DB's+ # permission bits onto the temp file before the chmod below runs,+ # briefly exposing live cookies when the source DB is looser.+ shutil.copyfile(str(db_path), tmp_path)_lock_temp_cookie_copy(tmp_path)except Exception as e:logger.info("Failed to copy %s cookies database: %s", keychain_service, e)diff --git a/tests/test_chrome_cookies.py b/tests/test_chrome_cookies.pyindex 557659d0..3385eb26 100644--- a/tests/test_chrome_cookies.py+++ b/tests/test_chrome_cookies.py@@ -13,6 +13,7 @@ import pytestOPENSSL_AVAILABLE = shutil.which("openssl") is not None+from lib import chrome_cookiesfrom lib.chrome_cookies import (CHROME_COOKIES_DB,CHROME_IV_HEX,@@ -276,6 +277,33 @@ class TestUnencryptedCookies:assert result == {"auth_token": "plain_token_value"}+ @pytest.mark.skipif(os.name == "nt", reason="POSIX permission model does not apply on Windows")+ def test_temp_cookie_copy_never_world_readable(self, tmp_path):+ """The temp copy must stay private immediately after copying content."""+ db_path = tmp_path / "Cookies"+ _create_chrome_cookies_db(str(db_path), [+ (".x.com", "auth_token", "plain_token_value", b""),+ ])+ os.chmod(db_path, 0o644)++ observed = {}+ real_lock = chrome_cookies._lock_temp_cookie_copy++ def spy(path):+ observed["mode_after_copy"] = os.stat(path).st_mode & 0o777+ return real_lock(path)++ with mock.patch.object(chrome_cookies, "_lock_temp_cookie_copy", side_effect=spy):+ result = _extract_chromium_cookies_macos(+ db_path,+ "Chrome Safe Storage",+ ".x.com",+ ["auth_token"],+ )++ assert result == {"auth_token": "plain_token_value"}+ assert observed["mode_after_copy"] == 0o600+def test_plain_value_returned(self, tmp_path):"""Unencrypted cookies (value column populated) returned without decryption."""db_path = str(tmp_path / "Cookies")