Skip to content

Commit

Permalink
Add "Expire" operation for cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlaw1979 committed Jan 27, 2025
1 parent 29d0502 commit f03d1c2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion FiddlerImportNetlog/FiddlerInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace FiddlerImportNetlog
{
[ProfferFormat("NetLog JSON",
"Chromium's JSON-based event log format (v1.3.5.1). See https://textslashplain.com/2020/01/17/capture-network-logs-from-edge-and-chrome/ for more info.",
"Chromium's JSON-based event log format (v1.3.6). See https://textslashplain.com/2020/01/17/capture-network-logs-from-edge-and-chrome/ for more info.",
// We handle import of JSON files, whether uncompressed, or compressed with ZIP or GZ. I'm not completely sure I remember the implications
// of declaring .gz here, nor why .zip isn't mentioned. Is this about the drag/drop import feature?
".json;.gz"
Expand Down
33 changes: 24 additions & 9 deletions FiddlerImportNetlog/Importer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1444,17 +1444,28 @@ private void ParseSessionsFromBucket(KeyValuePair<int, List<Hashtable>> kvpUR)
// bool bIsLegacyCookie = (htParams["msft_browser_legacy_cookie"] as Boolean) ?? false;
// string bBrowserProvenance = (htParams["browser_provenance"] as string) ?? String.Empty /*Native*/;

// TODO: As of Chrome 81, CookieInclusionStatusNetLogParams also adds |domain| and |path| attributes available if "sensitive" data is included.
// TODO: As of Chrome 81, CookieInclusionStatusNetLogParams also adds |domain| and |path| attributes available if "sensitive" data is included.

// In Chrome 81.3993, the |exclusion_reason| field was renamed to |status| because the |cookie_inclusion_status| entries are
// now also emitted for included cookies.
string sExclusionReasons = (htParams["exclusion_reason"] as string);
if (String.IsNullOrEmpty(sExclusionReasons)) sExclusionReasons = (htParams["status"] as string) ?? String.Empty;
// In Chrome 81.3993, the |exclusion_reason| field was renamed to |status| because the |cookie_inclusion_status| entries are
// now also emitted for included cookies.
string sExclusionReasons = (htParams["exclusion_reason"] as string);
if (String.IsNullOrEmpty(sExclusionReasons)) sExclusionReasons = (htParams["status"] as string) ?? String.Empty;

// If the log indicates that the cookie was included, just skip it for now.
// TODO: Offer a richer cookie-debugging story that exposes the domain/path/inclusion status.
// https://source.chromium.org/chromium/chromium/src/+/master:net/cookies/canonical_cookie.cc;l=899?q=GetDebugString%20cookie&ss=chromium&originalUrl=https:%2F%2Fcs.chromium.org%2F
if (sExclusionReasons.OICContains("include")) continue;
if (sExclusionReasons.OICContains("include"))
{
if ("expire" == sOperation)
{
// EXCLUDE_INVALID_DOMAIN,EXCLUDE_OVERWRITE_HTTP_ONLY,EXCLUDE_OVERWRITE_SECURE,
// EXCLUDE_FAILURE_TO_STORE (e.g. Set-Cookie header > 4096 characters),
// EXCLUDE_NONCOOKIEABLE_SCHEME,EXCLUDE_INVALID_PREFIX
listCookieSetExclusions.Add(String.Format("The cookie '{0}' was sent already expired.", sCookieName));
}

// TODO: Offer a richer cookie-debugging story that exposes the domain/path/inclusion status.
continue;
}

// See |ExclusionReason| list in https://cs.chromium.org/chromium/src/net/cookies/canonical_cookie.h?type=cs&q=EXCLUDE_SAMESITE_LAX&sq=package:chromium&g=0&l=304
// EXCLUDE_HTTP_ONLY, EXCLUDE_SECURE_ONLY,EXCLUDE_DOMAIN_MISMATCH,EXCLUDE_NOT_ON_PATH,EXCLUDE_INVALID_PREFIX
Expand All @@ -1469,6 +1480,10 @@ private void ParseSessionsFromBucket(KeyValuePair<int, List<Hashtable>> kvpUR)
// EXCLUDE_NONCOOKIEABLE_SCHEME,EXCLUDE_INVALID_PREFIX
listCookieSetExclusions.Add(String.Format("Blocked set of '{0}' due to '{1}'", sCookieName, sExclusionReasons));
}
else if ("expire" == sOperation)
{
listCookieSetExclusions.Add(String.Format("Blocked expire (set) of '{0}' due to '{1}'", sCookieName, sExclusionReasons));
}
else if ("send" == sOperation)
{
// Don't warn about cookies which are obviously inapplicable
Expand Down Expand Up @@ -1552,7 +1567,7 @@ private void ParseSessionsFromBucket(KeyValuePair<int, List<Hashtable>> kvpUR)
bool bCookieSetFailed = listCookieSetExclusions.Count > 0;
if (bCookieSetFailed) {
dictSessionFlags["ui-backcolor"] = "#FF8080";
dictSessionFlags["ui-comments"] = "A Set-Cookie was ignored";
dictSessionFlags["ui-comments"] = "A cookie set by Set-Cookie was not stored.";
AnnotateHeadersWithUnstoredCookies(oRPH, listCookieSetExclusions);
}
BuildAndAddSession(ref oSF, oRQH, oRPH, msResponseBody, dictSessionFlags, sURL, sMethod, oTimers, cbDroppedResponseBody);
Expand All @@ -1573,7 +1588,7 @@ private static void AnnotateHeadersWithUnstoredCookies(HTTPResponseHeaders oRPH,
if (null == oRPH) return;
foreach (string sExclusion in listExclusions)
{
oRPH.Add("$NETLOG-CookieNotSet", sExclusion);
oRPH.Add("$NETLOG-CookieNotStored", sExclusion);
}

listExclusions.Clear();
Expand Down
8 changes: 6 additions & 2 deletions FiddlerImportNetlog/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

[assembly: AssemblyTitle("FiddlerImportNetlog")]
[assembly: AssemblyDescription("Import Chromium NetLog events to Fiddler")]
[assembly: AssemblyCopyright("Copyright ©2024 Eric Lawrence")]
[assembly: AssemblyCopyright("Copyright ©2025 Eric Lawrence")]
[assembly: System.Resources.NeutralResourcesLanguage("en-US")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.3.5.1")] // ALWAYS UPDATE THE VERSION in the [ProfferFormat] attribute in FiddlerInterface.cs to match!
[assembly: AssemblyVersion("1.3.6.0")] // ALWAYS UPDATE THE VERSION in the [ProfferFormat] attribute in FiddlerInterface.cs to match!
[assembly: Fiddler.RequiredVersion("4.6.0.0")]


Expand All @@ -20,6 +20,10 @@ HTTP_STREAM_JOB has a binding between the request and the socket. Hook them up s
--> source_dependency = 1701 (URL_REQUEST)
*/

// v.1.3.6.0
// Support "expire" for cookies (added in Chrome 134)
// Update copyright to 2025

// v.1.3.5.1
// Add support for truncated file recovery.

Expand Down
2 changes: 1 addition & 1 deletion installer/FiddlerImportNetLog.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ VIProductVersion "${VER_ADDON}"
VIAddVersionKey "FileVersion" "${VER_ADDON}"
VIAddVersionKey "ProductName" "Fiddler NetLog Importer"
VIAddVersionKey "Comments" "https://textslashplain.com/"
VIAddVersionKey "LegalCopyright" "©2023 Eric Lawrence"
VIAddVersionKey "LegalCopyright" "©2025 Eric Lawrence"
VIAddVersionKey "CompanyName" "Eric Lawrence"
VIAddVersionKey "FileDescription" "Installer for Fiddler Fiddler NetLog Importer"

Expand Down

0 comments on commit f03d1c2

Please sign in to comment.