mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 01:32:19 +00:00
Let Idaho, questions and long place names through, and keep more tokens and codes private
"Boise ID 83702" names Idaho rather than an identity number. A long question
for the assistant is no recovery phrase: a phrase holds none of the common
words its list lacks ("the", "and", "are"). A long lower-case place name
is no passphrase, an address of up to ten words is sent as the Omnibar reads
it, and "mfa boston", "otp bank" and "security code plaza" are names.
"Authorization: Bearer" and any value after "bearer" but a place word are
tokens, and so are GitLab, Hugging Face and SendGrid keys and a code in a
link. Door, alarm and lockbox numbers (not a zip or area code), a spaced UK
National Insurance number, "my id is …", and emails spelled with "punto",
"period", a spaced dot or letter by letter are private too.
Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
35049fd7f7
commit
200c788ac1
3 files changed
+155
-37
No files matched your search
+19
-6
@@ -8026,11 +8026,13 @@ while the tab is hidden.
|
||||
A place search on its own runs through Location and shares its cancellation
|
||||
and errors, keeping the separate Location draft intact.
|
||||
|
||||
While typing, a short line (six words or fewer, no `?`, not a command,
|
||||
While typing, a short line (six words or fewer, ten with a number in it
|
||||
as an address has, no `?`, not a command,
|
||||
coordinates, a hex code, a callsign such as UAL2110 or N123AB, and nothing
|
||||
that may be private) is sent to
|
||||
Photon for place suggestions (the suggester itself never sends a line of
|
||||
more than eight words): at most one request every 500 ms per tab,
|
||||
more than eight words, or ten with a number): at most one request every
|
||||
500 ms per tab,
|
||||
and none for a minute after a refusal. Photon is the keyless geocoder the
|
||||
place search already uses; a submitted search is not part of this spacing.
|
||||
A line that may be one name ("Satellite Beach") is looked up whole. While
|
||||
@@ -8087,7 +8089,8 @@ key", "access token" or "secret key" followed by a word of six characters
|
||||
or more, the word for "password" in the interface's languages
|
||||
(contraseña, Passwort, mot de passe, пароль…) followed by anything, or "pin"
|
||||
(also "pin code", "pin number", "pin is") followed by a digit; a word
|
||||
starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_` or a Slack token's `xoxb-` and the like (any case) or
|
||||
starting `sk_`, `sk-`, `rk_`, `pk_live`, `ghp_`, `github_pat_`, `glpat-`, `hf_`, a SendGrid
|
||||
`SG.` key or a Slack token's `xoxb-` and the like (any case) or
|
||||
`AIza` or `eyJ`, or an AWS key id (`AKIA` and twelve capitals or digits
|
||||
more; "Akiak" is a place); or a word that may be a password or key, with letters and digits mixed
|
||||
within one run (a number beside a word, as in "Yanino-1", "2-chōme" or
|
||||
@@ -8109,13 +8112,23 @@ to search it as a place on purpose ("Search … as a place anyway"), which
|
||||
runs the ordinary place search and its online services only when picked; a
|
||||
bare number, an email or handle, a password, key, code or IBAN gets none.
|
||||
A suggested house is named by its number and its street (or, without a
|
||||
street, its locality) in the order its country writes them: "10 Downing
|
||||
street, its locality, district or city) in the order its country writes them: "10 Downing
|
||||
Street", "Hauptstraße 12".
|
||||
A nine-digit number or a short phone number written with no such word
|
||||
still gets the row: only picking it sends anything. One-time and verification codes,
|
||||
OTP, 2FA, MFA, CVV and CVC values, "card ending" digits, passphrases,
|
||||
recovery or seed phrases, "my secret is …" and an email spelled out ("john
|
||||
at example dot com") are private too. Text that parses as coordinates or a
|
||||
recovery or seed phrases (twelve to twenty-four short words with none of
|
||||
the common words a phrase list lacks, such as "the", "and" or "are", so a
|
||||
long question still goes to Ask GEV), "my secret is …", an email spelled
|
||||
out ("john at example dot com", "punto com", or letter by letter), a door,
|
||||
alarm or lockbox number ("code 4821"; "zip code 90210" and "area code 415"
|
||||
are places), "Authorization: Bearer …", a code in a link (`?code=…`), a
|
||||
spaced UK National Insurance number and "my id is …" are private too.
|
||||
"Boise ID 83702" names Idaho. Some private text is not caught: a
|
||||
passphrase run together as one word (a long place name is one word too),
|
||||
a lower-case word after "otp", "2fa" or "mfa" ("mfa boston" is a name;
|
||||
"otp ABCDEF" is caught) and a code of letters after "pin" or "gate code".
|
||||
A Japanese postcode after a Latin name is refused ("Shibuya 150-0002"). Text that parses as coordinates or a
|
||||
grid reference is not private. A place's name is six words at most, or ten
|
||||
when it has a number in it (an address: "1600 Pennsylvania Ave NW
|
||||
Washington DC 20500"). The places picked from the Omnibar's rows and chips that carry a position
|
||||
|
||||
@@ -71,8 +71,43 @@ export function onlyNumbersLookPrivate(text) {
|
||||
const REQUEST_START =
|
||||
/^(?:show|hide|turn|switch|find|search|go|fly|take|zoom|open|close|play|what|where|when|which|who|how|why|list|display|enable|disable|remove|clear|follow|track)\b/;
|
||||
|
||||
/** The most words a line sent for place suggestions may have. */
|
||||
const SUGGEST_MAX_WORDS = 8;
|
||||
/**
|
||||
* The most words a line sent for place suggestions may have: as many as the
|
||||
* Omnibar reads as a place's name (ten with a number, as an address has).
|
||||
*/
|
||||
const suggestMaxWords = (text) => (/\d/.test(text) ? 10 : 8);
|
||||
|
||||
/**
|
||||
* Common words no wallet's recovery phrase holds (they are not on the BIP39
|
||||
* list): a line with one is a sentence, however many short words it has.
|
||||
*/
|
||||
const NOT_SEED_WORDS = new Set([
|
||||
'the',
|
||||
'and',
|
||||
'are',
|
||||
'for',
|
||||
'from',
|
||||
'with',
|
||||
'how',
|
||||
'why',
|
||||
'which',
|
||||
'would',
|
||||
'could',
|
||||
'should',
|
||||
'please',
|
||||
'does',
|
||||
'was',
|
||||
'were',
|
||||
'flights',
|
||||
'show',
|
||||
]);
|
||||
|
||||
/**
|
||||
* "Boise ID 83702": Idaho's code before a ZIP code, after a town's name
|
||||
* (not after "My" or "Employee", whose "ID" is an identity number).
|
||||
*/
|
||||
const IDAHO_BEFORE_ZIP =
|
||||
/(?<=(?:^|\s)(?!(?:My|Your|Our|His|Her|Their|Employee|Student|Staff|Member|User|Customer|Patient|National|Voter|Photo|Tax|Card)\b)\p{Lu}\p{Ll}+,?\s)ID(?=\.?,?\s+\d{5}(?:-\d{4})?(?!\S))/gu;
|
||||
|
||||
/**
|
||||
* Words that say a number is an account, a card, a phone or a secret, in the
|
||||
@@ -93,7 +128,8 @@ function foldLine(text) {
|
||||
.replace(/\p{Cf}/gu, '')
|
||||
.replace(/[\u2018\u2019]/g, "'")
|
||||
.replace(/(?![0-9])\p{Nd}/gu, '0')
|
||||
.replace(/\s+/g, ' ');
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(IDAHO_BEFORE_ZIP, 'Idaho');
|
||||
}
|
||||
|
||||
/** A US ZIP+4 after a state's code or name, as an address writes it. */
|
||||
@@ -131,15 +167,21 @@ function privacyReason(text) {
|
||||
// An email written around a filter: "john(at)gmail.com",
|
||||
// "john[at]gmail[dot]com", "john at gmail dot com".
|
||||
// Also "john at gmail.com" and a "(dot)" or "[dot]" in any of them.
|
||||
// Spaced letter by letter ("j o h n @ g m a i l . c o m").
|
||||
if (
|
||||
/(?:^|\s)(?:\S\s){3,}@\s?(?:\S\s?){2,}/u.test(line) &&
|
||||
/[^@]@[\p{L}\p{N}-]+\.\p{L}{2,}/u.test(line.replace(/\s+/g, ''))
|
||||
)
|
||||
return 'other';
|
||||
if (
|
||||
/[\p{L}\p{N}._%+-]\s*[([{<]\s*at\s*[)\]}>]\s*[\p{L}\p{N}-]/iu.test(line) ||
|
||||
/\b\S+\s+at\s+\S+\s+(?:dot|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test(
|
||||
/\b\S+\s+at\s+\S+\s+(?:dot|punto|ponto|period|point|punkt|[([{<]\s*dot\s*[)\]}>])\s+\p{L}{2,24}\b/iu.test(
|
||||
line,
|
||||
) ||
|
||||
/\b\S+\s+at\s+[\p{L}\p{N}-]+\s*[([{<]\s*dot\s*[)\]}>]\s*\p{L}{2,24}\b/iu.test(
|
||||
line,
|
||||
) ||
|
||||
/\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\.(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test(
|
||||
/\b[\p{L}\p{N}._%+-]+\s+at\s+[\p{L}\p{N}-]+(?:\.[\p{L}\p{N}-]+)*\s*\.\s*(?:com|net|org|edu|gov|mil|io|co|me|info|biz|app|dev|ai|[a-z]{2})\b/iu.test(
|
||||
line,
|
||||
)
|
||||
)
|
||||
@@ -160,23 +202,20 @@ function privacyReason(text) {
|
||||
})
|
||||
)
|
||||
return 'other';
|
||||
// A wallet's recovery phrase: 12, 15, 18, 21 or 24 words, all of three
|
||||
// to eight letters in lower case ("abandon ability able …"), unless it
|
||||
// starts as a request does ("show flights over texas …"). A line that
|
||||
// long is never sent for suggestions anyway (see SUGGEST_MAX_WORDS).
|
||||
const words = line.trim().split(/\s+/);
|
||||
// A wallet's recovery phrase, whole or nearly ("abandon ability able
|
||||
// …"): twelve to twenty-four words of three to eight letters, none a
|
||||
// common word the phrase list lacks ("can you tell where the most …" is
|
||||
// a question), and not starting as a request does. Too long to be sent
|
||||
// for suggestions anyway, it is kept from the assistant too.
|
||||
const words = line.trim().toLowerCase().split(/\s+/);
|
||||
if (
|
||||
[12, 15, 18, 21, 24].includes(words.length) &&
|
||||
words.length >= 12 &&
|
||||
words.length <= 24 &&
|
||||
words.every((word) => /^[a-z]{3,8}$/.test(word)) &&
|
||||
!REQUEST_START.test(line)
|
||||
!words.some((word) => NOT_SEED_WORDS.has(word)) &&
|
||||
!REQUEST_START.test(words[0])
|
||||
)
|
||||
return 'other';
|
||||
// A passphrase run together ("correcthorsebatterystaple"): a line that
|
||||
// is one word of twenty letters or more, all lower case. A long place
|
||||
// name is written with its capital ("Llanfairpwllgwyngyll"), and a long
|
||||
// word inside a name ("… selskokhozyaystvennoy opytnoy stantsii") has
|
||||
// others beside it.
|
||||
if (words.length === 1 && /^[a-z]{20,}$/.test(words[0])) return 'other';
|
||||
// Coordinates and grid references are a spot, not a number to keep: only
|
||||
// text the place search itself reads as coordinates, as typed ("١٢٣٤,
|
||||
// ٥٦٧٨" folded would read as a spot, but is not one).
|
||||
@@ -275,7 +314,27 @@ function privacyReason(text) {
|
||||
/\b(?:pin|otp|2fa|mfa|cvv|cvc|(?:door|access|gate|alarm|entry|security|verification|one-time|auth|login) code)\s*(?:[:=#]|\s[-–—]\s|-)\s*[a-z0-9]/i.test(
|
||||
line,
|
||||
) ||
|
||||
codeAfterLabel(line)
|
||||
codeAfterLabel(line) ||
|
||||
// A door, alarm or lockbox number ("code 4821", "garage code 4821",
|
||||
// "the code to my door is 4821").
|
||||
// A postcode, dialling code or airport code is not one ("zip code
|
||||
// 90210", "area code 415").
|
||||
/\b(?<!\b(?:zip|postal|post|postcode|area|country|dialing|dialling|airport|iata|icao|country)\s)(?:code|alarm|lockbox|lock box|combination|combo|keypad)\s*[:=#]?\s*\d{3,8}\b/i.test(
|
||||
line,
|
||||
) ||
|
||||
/\b(?<!\b(?:zip|postal|post|area|country|dialing|dialling|airport)\s)code\b.{0,30}?\bis\s*[:=]?\s*\d{3,8}\b/i.test(
|
||||
line,
|
||||
) ||
|
||||
// A UK National Insurance number, spaced ("AB 12 34 56 C").
|
||||
/\b[A-Z]{2}\s?\d{2}\s?\d{2}\s?\d{2}\s?[A-D]\b/.test(line) ||
|
||||
// "my id is AB12345", "id no. 4471".
|
||||
/\bid\s+(?:is|no\.?|number|#)\s*[:=#]?\s*(?=[a-z0-9-]*\d)[a-z0-9-]{4,}/i.test(
|
||||
line,
|
||||
) ||
|
||||
// A one-time code in a link ("…/callback?code=abcdef").
|
||||
/[?&](?:code|token|access_token|key|sig|signature|auth)=[^&\s]{4,}/i.test(
|
||||
line,
|
||||
)
|
||||
)
|
||||
return 'other';
|
||||
if (
|
||||
@@ -286,7 +345,10 @@ function privacyReason(text) {
|
||||
.map((token) => token.replace(/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu, ''))
|
||||
.some(
|
||||
(token) =>
|
||||
/^(?:sk[-_]|rk_|pk_live|ghp_|xox[abposr]-)/i.test(token) ||
|
||||
/^(?:sk[-_]|rk_|pk_live|ghp_|gho_|ghu_|ghs_|github_pat_|glpat-|hf_|xox[abposr]-)/i.test(
|
||||
token,
|
||||
) ||
|
||||
/^SG\.[\w-]{8,}\.[\w-]{8,}$/.test(token) ||
|
||||
/^(?:AIza|eyJ)/.test(token) ||
|
||||
/^AKIA[0-9A-Z]{12,}$/.test(token) ||
|
||||
mayBeSecret(token),
|
||||
@@ -296,14 +358,15 @@ function privacyReason(text) {
|
||||
return longNumber ? 'number' : null;
|
||||
}
|
||||
|
||||
/** A value after "bearer" that is not a capitalised name ("Bearer Island"). */
|
||||
/**
|
||||
* A value after "bearer" that is not a word a place's name is made of
|
||||
* ("Bearer Island"); after "Authorization:" any value is a token.
|
||||
*/
|
||||
function bearerToken(line) {
|
||||
if (/\bauthori[sz]ation\s*:\s*bearer\b\s*\S/i.test(line)) return true;
|
||||
for (const match of line.matchAll(/\bbearer\b\s*[:=#]?\s*(\S+)/gi)) {
|
||||
const value = match[1].replace(/[,.;:!?)]+$/, '');
|
||||
// A name: capitalised and short ("Bearer Island, Canada"), or a word
|
||||
// a place's name is made of ("bearer island").
|
||||
if (/^\p{Lu}\p{Ll}{1,11}$/u.test(value) || PLACE_WORDS.test(value))
|
||||
continue;
|
||||
if (PLACE_WORDS.test(value)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -311,7 +374,7 @@ function bearerToken(line) {
|
||||
|
||||
/** Words a place's name is made of, after a label word ("bearer island"). */
|
||||
const PLACE_WORDS =
|
||||
/^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village)$/i;
|
||||
/^(?:island|islands|isle|lake|creek|river|point|bay|mountain|mount|hill|hills|valley|station|road|street|lane|avenue|park|beach|falls|springs?|county|city|town|village|plaza|square|mall|center|centre|tower|building|court|bank)$/i;
|
||||
|
||||
/**
|
||||
* A code after a label that can only be a code, without a colon ("PIN
|
||||
@@ -332,8 +395,15 @@ function codeAfterLabel(line) {
|
||||
if (coded) {
|
||||
const [, label, value] = coded;
|
||||
const labelIsName = /\p{Lu}/u.test(label);
|
||||
if (!labelIsName) return true;
|
||||
if (!/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true;
|
||||
// A word a place's name is made of is no code ("security code plaza",
|
||||
// "otp bank"); after the short labels a code in letters is written in
|
||||
// capitals ("otp ABCDEF"), so a lower-case word is a name ("mfa
|
||||
// boston").
|
||||
const shortLabel = /^(?:otp|2fa|mfa)\b/i.test(label);
|
||||
const named =
|
||||
PLACE_WORDS.test(value) || (shortLabel && /^\p{Ll}+$/u.test(value));
|
||||
if (!labelIsName && !named) return true;
|
||||
if (labelIsName && !/^\p{Lu}(?:\p{Ll}+|\p{Lu}+)$/u.test(value)) return true;
|
||||
}
|
||||
// A value in mixed case that is no name ("PIN aBcD", "gate code aBcD").
|
||||
const mixed =
|
||||
@@ -466,7 +536,7 @@ export function createPlaceSuggester({
|
||||
if (
|
||||
!enabled ||
|
||||
text.length < minPlaceChars(text) ||
|
||||
text.split(/\s+/).length > SUGGEST_MAX_WORDS ||
|
||||
text.split(/\s+/).length > suggestMaxWords(text) ||
|
||||
mayBePrivate(text)
|
||||
)
|
||||
return [];
|
||||
|
||||
@@ -437,14 +437,31 @@ test('spelled-out emails, addresses, phrases, codes and short phone numbers stay
|
||||
'john at gmail dot de',
|
||||
'10.0.0.1',
|
||||
'abandon ability able about above absent absorb abstract absurd abuse access accident',
|
||||
'correcthorsebatterystaple',
|
||||
'Abandon ability able about above absent absorb abstract absurd abuse access accident acid',
|
||||
'license ABC1234',
|
||||
'passport X1234567',
|
||||
'plate 7ABC123',
|
||||
'otp abcdef',
|
||||
'otp ABCDEF',
|
||||
'verification code abcdef',
|
||||
'cvv abc',
|
||||
'Bearer abcdef',
|
||||
'Bearer Abcdefgh',
|
||||
'Authorization: Bearer Xyz',
|
||||
'glpat-abcdef123456',
|
||||
'hf_abcdefghijk',
|
||||
'SG.abcdefghij.klmnopqrstuv',
|
||||
'https://x.com/?code=abcdef',
|
||||
'code 4821',
|
||||
'garage code 4821',
|
||||
'lockbox 4821',
|
||||
'the code to my door is 4821',
|
||||
'AB 12 34 56 C',
|
||||
'my id is AB12345',
|
||||
'My ID 12345',
|
||||
'john at gmail .com',
|
||||
'john at gmail punto com',
|
||||
'john.doe at example period com',
|
||||
'j o h n @ g m a i l . c o m',
|
||||
'ssn 123',
|
||||
'Jo 12345-6789',
|
||||
'Joe 1234 12345 thanks',
|
||||
@@ -468,6 +485,19 @@ test('places that only looked private are looked up', () => {
|
||||
'Idaho Falls',
|
||||
'meet at 12:30:45',
|
||||
'Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch',
|
||||
'llanfairpwllgwyngyll',
|
||||
'Boise ID 83702',
|
||||
'Boise, ID 83702',
|
||||
'Hayden ID 83835-1234',
|
||||
'mfa boston',
|
||||
'otp bank',
|
||||
'security code plaza',
|
||||
'zip code 90210',
|
||||
'area code 415',
|
||||
'Settipalle @ K.Bandarlapalle',
|
||||
// Questions for the assistant, however many short words they have.
|
||||
'can you tell where the most flights are going over texas today',
|
||||
'are there any storms near florida right now that might cause delays',
|
||||
'OTP Bank',
|
||||
// A long request is not a recovery phrase.
|
||||
'show flights over texas near austin with altitude above thirty thousand feet please',
|
||||
@@ -560,4 +590,9 @@ test('a line longer than a place name is never sent for suggestions', async () =
|
||||
[],
|
||||
);
|
||||
assert.equal(sent, 0);
|
||||
// An address has more words: as many as the Omnibar reads as a place.
|
||||
await service.suggest('350 Fifth Avenue, New York, NY 10118, United States');
|
||||
assert.equal(sent, 1);
|
||||
await service.suggest('1 2 3 4 5 6 7 8 9 10 11');
|
||||
assert.equal(sent, 1);
|
||||
});
|
||||
Reference in new issue
Block a user