Rapporto di diagnostica della raccolta (#39)
Dopo una prova dal vivo andata male, Alberto deve poter mandare un solo file che spieghi perché, senza che nessuno veda dati di altre persone. Attività ha ora il pulsante «Diagnostica», che scarica il rapporto delle sessioni degli ultimi 14 giorni: pagine aperte e forma degli indirizzi, risposte per tipo, stato e dimensione con ciò che i lettori ne hanno fatto, struttura stretta delle forme sconosciute, ricette, segnali, permessi negati, file in coda e scaricati, e il motivo di ogni arresto. Nel rapporto entrano solo valori da elenchi chiusi, numeri, orari e forme: mai nomi, indirizzi completi, codici, cursori, cookie o pezzi di risposte. Le forme degli indirizzi e la regola delle chiavi-dato passano dalla sonda a Core, e la sonda le richiama. Il registratore non lancia mai eccezioni verso la raccolta e tiene i file in Dati/diagnostica per 14 giorni. Prova che il rapporto non contiene valori, con controlli di mutazione; tre giri di revisione avversaria (25 difetti confermati, tutti corretti). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf03cb45a5
commit
badd1681a0
55 files changed
+5395
-134
No files matched your search
@@ -4,6 +4,7 @@ using System.Text.Json.Nodes;
|
||||
using System.Text.RegularExpressions;
|
||||
using Febe.Core.Abstractions;
|
||||
using Febe.Core.Collection;
|
||||
using Febe.Core.Collection.Privacy;
|
||||
|
||||
namespace Febe.Sonda;
|
||||
|
||||
@@ -49,22 +50,6 @@ public static partial class RequestShapes
|
||||
/// <summary>The body field that describes a request body that is neither a form nor a JSON object.</summary>
|
||||
public const string WholeBody = "(corpo)";
|
||||
|
||||
/// <summary>
|
||||
/// Path segments kept as they are: words of the site's addresses, the same for everyone. Anything else (user names,
|
||||
/// identifiers, codes) becomes <c>{numero}</c> or <c>{testo}</c>. A missing word only costs detail, never privacy.
|
||||
/// </summary>
|
||||
private static readonly HashSet<string> KnownSegments = new(StringComparer.Ordinal)
|
||||
{
|
||||
"api", "v1", "graphql", "graphql_www", "query", "ajax", "bulk-route-definitions", "navigation", "web", "users",
|
||||
"user", "web_profile_info", "usernameinfo", "info", "feed", "timeline", "reels_media", "reels_tray", "highlights",
|
||||
"highlights_tray", "friendships", "following", "followers", "show", "show_many", "search", "topsearch", "fbsearch",
|
||||
"web_search", "typeahead", "accounts_typeahead", "top_serp", "media", "comments", "usertags", "clips", "stories",
|
||||
"story", "tags", "sections", "discover", "explore", "chaining", "profile", "posts", "reels", "tagged", "saved",
|
||||
"qp", "batch_fetch_web", "logging_client_events", "direct_v2", "inbox", "has_new", "get_presence", "wwwgraphql",
|
||||
"ig", "bz", "web_info", "current_user", "user_info", "locations", "seen", "media_seen", "reel", "p", "accounts",
|
||||
"edit", "activity", "news", "inbox_v2", "notifications", "badge", "home", "graphql_query",
|
||||
};
|
||||
|
||||
/// <summary>Request headers whose value is the same for everyone and is kept; any other value is removed.</summary>
|
||||
private static readonly HashSet<string> KnownHeaderValues = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
@@ -199,24 +184,9 @@ public static partial class RequestShapes
|
||||
return new RequestShapesReport(count, described, shapes.Count, names.Removed) { Truncated = truncated, DroppedEntry = droppedEntry };
|
||||
}
|
||||
|
||||
/// <summary>The path with each segment that is not a known word replaced by <c>{numero}</c> or <c>{testo}</c>.</summary>
|
||||
public static string PathPattern(string path)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
var segments = path.Split('/');
|
||||
for (var i = 0; i < segments.Length; i++)
|
||||
{
|
||||
var segment = segments[i];
|
||||
if (segment.Length == 0 || KnownSegments.Contains(segment))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
segments[i] = Digits().IsMatch(segment) ? "{numero}" : "{testo}";
|
||||
}
|
||||
|
||||
return string.Join('/', segments);
|
||||
}
|
||||
/// <summary>The path with each segment that is not a known word replaced by <c>{numero}</c> or <c>{testo}</c>
|
||||
/// (<see cref="PathPatterns.Of"/>, shared with the diagnostic report).</summary>
|
||||
public static string PathPattern(string path) => PathPatterns.Of(path);
|
||||
|
||||
/// <summary>
|
||||
/// The kind of the value of <paramref name="name"/>, never the value: «numero», «vuoto» or «testo». Kept as they are:
|
||||
|
||||
@@ -72,9 +72,8 @@ public sealed class SensitiveTokens
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>True when the key is data rather than structure (sanitizer replaces it).</summary>
|
||||
public static bool IsDataKey(string key) =>
|
||||
KeyStructure.LooksLikeIdentifier(key) || key.Any(c => !(char.IsAsciiLetterOrDigit(c) || c is '_' or '-'));
|
||||
/// <summary>True when the key is data rather than structure (sanitizer replaces it): <see cref="KeyStructure.IsDataKey"/>.</summary>
|
||||
public static bool IsDataKey(string key) => KeyStructure.IsDataKey(key);
|
||||
|
||||
private void Walk(JsonElement element, string? key, int depth)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user