Skip to content

Commit

Permalink
Merge pull request #104 from fingerprintjs/false-positive-fix
Browse files Browse the repository at this point in the history
Fix false positives
  • Loading branch information
xnerhu authored Nov 28, 2022
2 parents a105282 + 5fc258d commit 20b5a26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 5 additions & 4 deletions src/detectors/eval_length.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { arrayIncludes } from '../utils/ponyfills'
import { BrowserKind, ComponentDict, DetectorResponse, State } from '../types'
import { getBrowserKind } from '../utils/browser'
import { BrowserEngineKind, BrowserKind, ComponentDict, DetectorResponse, State } from '../types'
import { getBrowserEngineKind, getBrowserKind } from '../utils/browser'

export function detectEvalLengthInconsistency({ evalLength }: ComponentDict): DetectorResponse {
if (evalLength.state !== State.Success) return
const length = evalLength.value
const browser = getBrowserKind()
const browserEngine = getBrowserEngineKind()
return (
(length === 37 && !arrayIncludes([BrowserKind.Firefox, BrowserKind.Safari], browser)) ||
(length === 37 && !arrayIncludes([BrowserEngineKind.Webkit, BrowserEngineKind.Gecko], browserEngine)) ||
(length === 39 && !arrayIncludes([BrowserKind.IE], browser)) ||
(length === 33 && !arrayIncludes([BrowserKind.Chrome, BrowserKind.Opera, BrowserKind.WeChat], browser))
(length === 33 && !arrayIncludes([BrowserEngineKind.Chromium], browserEngine))
)
}
9 changes: 4 additions & 5 deletions src/detectors/plugins_inconsistency.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { BotKind, BrowserEngineKind, BrowserKind, ComponentDict, DetectorResponse, State } from '../types'
import { getBrowserEngineKind, getBrowserKind, isAndroid, isDesktopSafari } from '../utils/browser'
import { BotKind, BrowserEngineKind, ComponentDict, DetectorResponse, State } from '../types'
import { getBrowserEngineKind, isAndroid, isDesktopSafari } from '../utils/browser'

export function detectPluginsLengthInconsistency({ pluginsLength }: ComponentDict): DetectorResponse {
if (pluginsLength.state !== State.Success) return
const browserKind = getBrowserKind()
const browserEngineKind = getBrowserEngineKind()
// Chromium based android browsers and mobile safari have 0 plugins length.
// Chromium based android browsers and mobile webkit based browsers have 0 plugins length.
if (
(browserEngineKind === BrowserEngineKind.Chromium && isAndroid()) ||
(browserKind === BrowserKind.Safari && !isDesktopSafari())
(browserEngineKind === BrowserEngineKind.Webkit && !isDesktopSafari())
)
return
if (pluginsLength.value === 0) return BotKind.HeadlessChrome
Expand Down

0 comments on commit 20b5a26

Please sign in to comment.