Bug 1638358 - Cookie Schemeful Same-Site - part 1 - scheme map in nsICookie, r=mayhemer

Differential Revision: https://phabricator.services.mozilla.com/D75624
This commit is contained in:
Andrea Marchesini 2020-06-02 13:48:28 +00:00
Родитель 6cec99e745
Коммит 01cf5e2ca5
7 изменённых файлов: 34 добавлений и 4 удалений

Просмотреть файл

@ -148,6 +148,10 @@ NS_IMETHODIMP Cookie::GetSameSite(int32_t* aSameSite) {
}
return NS_OK;
}
NS_IMETHODIMP Cookie::GetSchemeMap(nsICookie::schemeType* aSchemeMap) {
*aSchemeMap = static_cast<nsICookie::schemeType>(SchemeMap());
return NS_OK;
}
NS_IMETHODIMP
Cookie::GetOriginAttributes(JSContext* aCx, JS::MutableHandle<JS::Value> aVal) {

Просмотреть файл

@ -84,6 +84,7 @@ class Cookie final : public nsICookie {
}
inline int32_t SameSite() const { return mData.sameSite(); }
inline int32_t RawSameSite() const { return mData.rawSameSite(); }
inline uint8_t SchemeMap() const { return mData.schemeMap(); }
// setters
inline void SetExpiry(int64_t aExpiry) { mData.expiry() = aExpiry; }

Просмотреть файл

@ -131,6 +131,13 @@ void CookieLogging::LogCookie(Cookie* aCookie) {
("sameSite: %s - rawSameSite: %s\n",
SameSiteToString(aCookie->SameSite()),
SameSiteToString(aCookie->RawSameSite())));
MOZ_LOG(
gCookieLog, LogLevel::Debug,
("schemeMap %d (http: %s | https: %s | file: %s)\n",
aCookie->SchemeMap(),
(aCookie->SchemeMap() & nsICookie::SCHEME_HTTP ? "true" : "false"),
(aCookie->SchemeMap() & nsICookie::SCHEME_HTTPS ? "true" : "false"),
(aCookie->SchemeMap() & nsICookie::SCHEME_FILE ? "true" : "false")));
nsAutoCString suffix;
aCookie->OriginAttributesRef().CreateSuffix(suffix);

Просмотреть файл

@ -1686,9 +1686,9 @@ UniquePtr<CookieStruct> CookiePersistentStorage::GetCookieFromRow(
int32_t rawSameSite = aRow->AsInt32(IDX_RAW_SAME_SITE);
// Create a new constCookie and assign the data.
return MakeUnique<CookieStruct>(name, value, host, path, expiry, lastAccessed,
creationTime, isHttpOnly, false, isSecure,
sameSite, rawSameSite);
return MakeUnique<CookieStruct>(
name, value, host, path, expiry, lastAccessed, creationTime, isHttpOnly,
false, isSecure, sameSite, rawSameSite, nsICookie::SCHEME_UNSET);
}
void CookiePersistentStorage::EnsureReadComplete() {

Просмотреть файл

@ -732,7 +732,7 @@ CookieService::AddNative(const nsACString& aHost, const nsACString& aPath,
nsCString(aPath), aExpiry, currentTimeInUsec,
Cookie::GenerateUniqueCreationTime(currentTimeInUsec),
aIsHttpOnly, aIsSession, aIsSecure, aSameSite,
aSameSite);
aSameSite, nsICookie::SCHEME_UNSET);
RefPtr<Cookie> cookie = Cookie::Create(cookieData, key.mOriginAttributes);
MOZ_ASSERT(cookie);

Просмотреть файл

@ -119,4 +119,21 @@ interface nsICookie : nsISupports {
* - SAMESITE_STRICT - the SameSite attribute is present and strict
*/
readonly attribute int32_t sameSite;
/**
* The list of possible schemes of cookies. It's a bitmap because a cookie
* can be set on HTTP and HTTPS. At the moment, we treat it as the same
* cookie.
*/
cenum schemeType : 8 {
SCHEME_UNSET = 0x00,
SCHEME_HTTP = 0x01,
SCHEME_HTTPS = 0x02,
SCHEME_FILE = 0x04,
};
/**
* Bitmap of schemes.
*/
readonly attribute nsICookie_schemeType schemeMap;
};

Просмотреть файл

@ -436,6 +436,7 @@ struct CookieStruct
bool isSecure;
int32_t sameSite;
int32_t rawSameSite;
uint8_t schemeMap;
};
struct DocumentChannelCreationArgs {