Sessione salvata cifrata, copiata a «Ho finito» (#36, S4)
verifica / controlli (push) Successful in 22s
verifica / prove (push) Successful in 16m46s
verifica / installatore (push) Successful in 4m43s
verifica / immagine (push) Successful in 21m2s

Il client del sito ha bisogno della sessione del browser di Febe: ora la copia
c'è, cifrata e dietro un interruttore, senza cambiare nulla di predefinito.

- Opzione «raccolta» (pagine predefinita, richieste): solo con «richieste» e
  almeno un'operazione configurata si costruiscono sessione salvata, client del
  sito e copia. Con Instagram nulla cambia: le dieci operazioni restano non
  configurate (mancano __spin_*, __req, __s, __dyn, __csr e altri).
- Cookie con dominio, percorso, solo-host, Secure, HttpOnly e scadenza, mandati
  solo dove il browser li manderebbe (RFC 6265).
- Sezione «page» del catalogo: dove la pagina tiene ogni valore; nuovi campi rev,
  hs, hsi, dpr, ccg, comet_req, entry_nonce. Il caricatore rifiuta
  un'operazione configurata con un valore di sessione senza fonte nella pagina.
- Dati/sessione/sessione.json: DPAPI su Windows, AES-256-GCM in Docker (chiave
  da FEBE_CHIAVE_SESSIONE o chiave.bin), scrittura atomica, file illeggibile =
  nessuna sessione. «Scollega» la cancella; chiave.bin resta.
- Copia a «Ho finito» con Network.getCookies e una sola Runtime.evaluate in sola
  lettura, solo da una pagina del sito e finché dura il permesso di guida.
- FEBE_PASSWORD e FEBE_CHIAVE_SESSIONE non passano a Chromium, Xvfb, ffmpeg.
- Sito di prova: csrftoken, cookie limitato a /api/, registro di moduli suo.
- Revisione su tre lenti: 11 punti confermati, tutti corretti.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 16:43:43 +01:00
1 parent 3046b2da47
commit c87768766c
69 files changed
+5936 -415

No files matched your search

@@ -4,6 +4,7 @@ using System.Text.RegularExpressions;
using Febe.Core.Abstractions;
using Febe.Core.Collection;
using Febe.Core.Collection.Requests;
using Febe.Tests.Collection.Support;
namespace Febe.Tests.Collection;
@@ -36,7 +37,8 @@ public sealed partial class RequestCatalogTests
// Only what the shapes tell whole is configured: a variable whose name the probe removed, a value it does not
// show, or a header or field whose source is still pending leaves the operation not configured (rule 9). Every
// Instagram operation has such headers and fields until tappa S4; for four of them only those are missing.
// Instagram operation still has such headers and fields after S4 (values the page computes as it runs, headers of
// the browser, removed names); for four of them only those are missing.
Assert.AreEqual(0, instagram.Configured.Count());
CollectionAssert.AreEquivalent(
new[] { "PolarisProfileReelsTabContentQuery", "PolarisProfileTaggedTabContentQuery", "PolarisProfileStoryHighlightsTrayContentQuery", "media-info" },
@@ -326,6 +328,166 @@ public sealed partial class RequestCatalogTests
}
}
[TestMethod]
public void ThePageSectionSaysWhereThePageKeepsEachSessionValue()
{
var instagram = RequestCatalog.LoadInstagram().Page;
Assert.IsNotNull(instagram);
Assert.AreEqual("PolarisProfilePostsQuery_instagramRelayOperation", instagram.DocIdModuleFor("PolarisProfilePostsQuery"));
Assert.AreEqual(new PageValueSource("LSD", "token"), instagram.Values["lsd"]);
Assert.AreEqual(new PageValueSource("DTSGInitialData", "token"), instagram.Values["fb_dtsg"]);
Assert.AreEqual(new PageValueSource("CurrentUserInitialData", "USER_ID"), instagram.Values["account_id"]);
Assert.AreEqual(new PageValueSource("CurrentUserInitialData", "APP_ID"), instagram.Values["app_id"]);
Assert.AreEqual(new PageValueSource("SiteData", "client_revision"), instagram.Values["rev"]);
Assert.AreEqual(new PageValueSource("SiteData", "haste_session"), instagram.Values["hs"]);
Assert.AreEqual(new PageValueSource("SiteData", "hsi"), instagram.Values["hsi"]);
Assert.AreEqual(new PageValueSource("SiteData", "pr"), instagram.Values["dpr"]);
Assert.AreEqual(new PageValueSource("SiteData", "comet_env"), instagram.Values["comet_req"]);
Assert.AreEqual(new PageValueSource("WebConnectionClassServerGuess", "connectionClass"), instagram.Values["ccg"]);
Assert.AreEqual(new PageValueSource("BootloaderConfig", "nonce"), instagram.Values["entry_nonce"]);
CollectionAssert.AreEquivalent(SiteSessionValues.PageFields.ToArray(), instagram.Values.Keys.ToArray(), "A place for every page value.");
// The test site has its own module names, never Instagram's.
var prova = RequestCatalog.LoadTestSite().Page;
Assert.IsNotNull(prova);
Assert.AreEqual("ProvaProfiloQuery_operazioneProva", prova.DocIdModuleFor("ProvaProfiloQuery"));
CollectionAssert.AreEquivalent(SiteSessionValues.PageFields.ToArray(), prova.Values.Keys.ToArray());
var instagramModules = instagram.Values.Values.Select(v => v.Module).ToHashSet(StringComparer.OrdinalIgnoreCase);
Assert.IsFalse(prova.Values.Values.Any(v => instagramModules.Contains(v.Module)));
Assert.IsFalse(prova.DocIdModule!.Contains("instagram", StringComparison.OrdinalIgnoreCase));
Assert.IsTrue(prova.Values.Values.All(v => PageSources.IsIdentifier(v.Module) && PageSources.IsIdentifier(v.Property)));
}
[TestMethod]
public void TheInstagramVersionFieldsComeFromTheSessionAndAllTenOperationsStayNotConfigured()
{
var catalog = RequestCatalog.LoadInstagram();
Assert.AreEqual(0, catalog.Configured.Count(), "S4 configures no Instagram operation.");
var session = new Dictionary<string, string>
{
["__rev"] = "rev", ["__hs"] = "hs", ["__hsi"] = "hsi", ["__ccg"] = "ccg", ["__comet_req"] = "comet_req", ["dpr"] = "dpr",
};
foreach (var operation in catalog.Operations.Where(o => o.Kind == OperationKind.GraphQl))
{
foreach (var (field, source) in session)
{
Assert.AreEqual(new ValueSource(ValueSourceKind.Session, source), operation.Body[field], $"{operation.Name} {field}");
}
Assert.AreEqual(new ValueSource(ValueSourceKind.Session, "entry_nonce"), operation.Headers["x-fb-entry-nonce"], operation.Name);
Assert.AreEqual(new ValueSource(ValueSourceKind.Constant, "359341"), operation.Headers["x-asbd-id"], "The BDHeaderConfig property is not established.");
foreach (var spin in new[] { "__spin_r", "__spin_b", "__spin_t" })
{
Assert.AreEqual(ValueSourceKind.Pending, operation.Body[spin].Kind, $"{operation.Name} {spin}: who adds it to the request is not shown.");
}
}
}
[TestMethod]
public void EveryPendingLeftIsARuntimeValueABrowserHeaderOrARemovedName()
{
// A closed list: what the page computes while it runs (__req, __s, __dyn, __csr, __hblp, __hsdp, __sjsp, __crn,
// __d, __spin_*, x-web-session-id), headers of the browser (referer, priority, sec-ch-ua*, x-ig-max-touch-points)
// and the names the probe removed. Nothing else may stay pending without a decision.
var allowed = new HashSet<string>(StringComparer.Ordinal)
{
"__req", "__s", "__dyn", "__csr", "__hblp", "__hsdp", "__sjsp", "__crn", "__d", "__spin_r", "__spin_b", "__spin_t",
"x-web-session-id", "referer", "priority", "sec-ch-ua", "sec-ch-ua-mobile", "sec-ch-ua-platform", "x-ig-max-touch-points",
"fb_api_analytics_tags", "qpl_active_flow_ids", RequestCatalog.RemovedName,
};
var pending = RequestCatalog.LoadInstagram().Operations.SelectMany(o => o.PendingValues).Distinct(StringComparer.Ordinal).ToList();
CollectionAssert.AreEqual(Array.Empty<string>(), pending.Where(p => !allowed.Contains(p)).ToArray());
Assert.IsFalse(pending.Contains("__rev") || pending.Contains("x-fb-entry-nonce"), "Settled in S4.");
Assert.AreEqual(0, RequestCatalog.LoadTestSite().Operations.Sum(o => o.PendingValues.Count));
}
[TestMethod]
[DataRow("""{"password": "Utente.password"}""", "password")]
[DataRow("""{"user_agent": "Navigatore.agente"}""", "user_agent")]
[DataRow("""{"claim": "Pagina.claim"}""", "claim")]
[DataRow("""{"doc_id": "Pagina.doc"}""", "doc_id")]
[DataRow("""{"lsd": "LSD.token;alert(1)"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": "LSD"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": "LSD.token.altro"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": "1LSD.token"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": "LSD.to-ken"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": "require('x').y"}""", "Modulo.proprietà")]
[DataRow("""{"lsd": ".token"}""", "Modulo.proprietà")]
public void ThePageSectionRefusesUnknownFieldsAndNamesThatAreNotIdentifiers(string values, string expected)
{
var file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.prova.json"))!.AsObject();
file["page"]!["values"] = JsonNode.Parse(values);
var refused = Refuse(file.ToJsonString());
StringAssert.Contains(refused, "page");
StringAssert.Contains(refused, expected);
}
[TestMethod]
[DataRow("Modulo_relay")]
[DataRow("{operation}_{operation}")]
[DataRow("{operation}-relay")]
[DataRow("{operation}.relay")]
[DataRow("{operazione}_relay")]
public void TheDocIdModuleHasTheOperationOnceAndIsOtherwiseAnIdentifier(string module)
{
var file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.prova.json"))!.AsObject();
file["page"]!["docIdModule"] = module;
StringAssert.Contains(Refuse(file.ToJsonString()), "docIdModule");
}
[TestMethod]
public void AConfiguredOperationWhoseSessionValueHasNoPlaceInThePageIsRefused()
{
// No module for lsd: the configured GraphQL query that sends it is refused, naming the value.
var file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.prova.json"))!.AsObject();
file["page"]!["values"]!.AsObject().Remove("lsd");
var refused = Refuse(file.ToJsonString());
StringAssert.Contains(refused, "session:lsd");
StringAssert.Contains(refused, "ProvaProfiloQuery");
StringAssert.Contains(refused, "regola 9");
// No doc_id module: every configured GraphQL query is refused.
file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.prova.json"))!.AsObject();
file["page"]!.AsObject().Remove("docIdModule");
StringAssert.Contains(Refuse(file.ToJsonString()), "session:doc_id");
// No page section at all: x-app-id (session:app_id) of the plain addresses has no place either.
file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.prova.json"))!.AsObject();
file.Remove("page");
StringAssert.Contains(Refuse(file.ToJsonString()), "session:");
// The user agent and the claim need no place in the page; an operation that is not configured waits anyway.
Assert.IsNotNull(RequestCatalog.Parse(Alone(Rest("post2", "/dati/post/{code}")), "richieste.prova.json"));
var waiting = Rest("post3", "/dati/post/{code}");
waiting["headers"] = new JsonObject { ["user-agent"] = "session:user_agent", ["x-app-id"] = "session:app_id" };
waiting["configured"] = false;
waiting["reason"] = "in attesa";
Assert.IsNotNull(RequestCatalog.Parse(Alone(waiting), "richieste.prova.json"));
// Instagram's page section names every value its operations use, so settling the pending ones would be enough.
Assert.AreEqual(4, SettledCatalog.Instagram().Configured.Count());
}
[TestMethod]
public void TheNewSessionFieldsAreAcceptedAndUnknownOnesStillRefused()
{
foreach (var field in new[] { "rev", "hs", "hsi", "dpr", "ccg", "comet_req", "entry_nonce" })
{
var operation = Rest("post2", "/dati/post/{code}");
operation["headers"] = new JsonObject { ["user-agent"] = "session:user_agent", ["x-prova"] = "session:" + field };
operation["configured"] = false;
operation["reason"] = "prova";
Assert.AreEqual(new ValueSource(ValueSourceKind.Session, field), Get(RequestCatalog.Parse(Alone(operation), "richieste.prova.json"), "post2").Headers["x-prova"]);
}
foreach (var field in new[] { "password", "spin_r", "cookie", "sessionid" })
{
var operation = Rest("post2", "/dati/post/{code}");
operation["headers"] = new JsonObject { ["x-prova"] = "session:" + field };
StringAssert.Contains(Refuse(Alone(operation)), "fonte");
}
}
private static SiteOperation Get(RequestCatalog catalog, string name) =>
catalog.TryGet(name, out var operation) ? operation : throw new AssertFailedException($"«{name}» non è nel catalogo.");