passbolt-styleguide 5.18.2 → 5.19.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_NOTES.md +7 -2
- package/build/css/themes/default/api_authentication.min.css +4 -4
- package/build/css/themes/default/api_main.min.css +4 -4
- package/build/css/themes/default/ext_app.min.css +4 -4
- package/build/css/themes/default/ext_authentication.min.css +4 -4
- package/build/css/themes/default/ext_external.min.css +2 -2
- package/build/css/themes/default/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/default/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/default/ext_quickaccess.min.css +4 -4
- package/build/css/themes/layette/api_authentication.min.css +4 -4
- package/build/css/themes/layette/api_main.min.css +4 -4
- package/build/css/themes/layette/ext_app.min.css +4 -4
- package/build/css/themes/layette/ext_authentication.min.css +4 -4
- package/build/css/themes/layette/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/layette/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/layette/ext_quickaccess.min.css +4 -4
- package/build/css/themes/midgar/api_authentication.min.css +4 -4
- package/build/css/themes/midgar/api_main.min.css +4 -4
- package/build/css/themes/midgar/ext_app.min.css +4 -4
- package/build/css/themes/midgar/ext_authentication.min.css +4 -4
- package/build/css/themes/midgar/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/midgar/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/midgar/ext_quickaccess.min.css +4 -4
- package/build/css/themes/sakura/api_authentication.min.css +4 -4
- package/build/css/themes/sakura/api_main.min.css +4 -4
- package/build/css/themes/sakura/ext_app.min.css +4 -4
- package/build/css/themes/sakura/ext_authentication.min.css +4 -4
- package/build/css/themes/sakura/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/sakura/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/sakura/ext_quickaccess.min.css +4 -4
- package/build/css/themes/solarized_dark/api_authentication.min.css +4 -4
- package/build/css/themes/solarized_dark/api_main.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_app.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_authentication.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/solarized_dark/ext_quickaccess.min.css +4 -4
- package/build/css/themes/solarized_light/api_authentication.min.css +4 -4
- package/build/css/themes/solarized_light/api_main.min.css +4 -4
- package/build/css/themes/solarized_light/ext_app.min.css +4 -4
- package/build/css/themes/solarized_light/ext_authentication.min.css +4 -4
- package/build/css/themes/solarized_light/ext_in_form_cta.min.css +4 -4
- package/build/css/themes/solarized_light/ext_in_form_menu.min.css +4 -4
- package/build/css/themes/solarized_light/ext_quickaccess.min.css +4 -4
- package/build/css/themes/themes.json +1 -0
- package/build/js/dist/api-account-recovery.js +1 -1
- package/build/js/dist/api-app.js +1 -1
- package/build/js/dist/api-feedback.js +1 -1
- package/build/js/dist/api-mfa-verify-delegated.js +1 -1
- package/build/js/dist/api-mfa-verify.js +1 -1
- package/build/js/dist/api-recover.js +1 -1
- package/build/js/dist/api-setup.js +1 -1
- package/build/js/dist/api-triage.js +1 -1
- package/build/locales/cs-CZ/common.json +167 -13
- package/build/locales/de-DE/common.json +165 -13
- package/build/locales/es-ES/common.json +165 -13
- package/build/locales/fr-FR/common.json +165 -13
- package/build/locales/it-IT/common.json +165 -13
- package/build/locales/ja-JP/common.json +164 -13
- package/build/locales/ko-KR/common.json +164 -13
- package/build/locales/lt-LT/common.json +167 -13
- package/build/locales/nl-NL/common.json +165 -13
- package/build/locales/pl-PL/common.json +167 -13
- package/build/locales/pt-BR/common.json +165 -13
- package/build/locales/ro-RO/common.json +166 -13
- package/build/locales/ru-RU/common.json +167 -13
- package/build/locales/sl-SI/common.json +167 -13
- package/build/locales/sv-SE/common.json +165 -13
- package/build/locales/uk-UA/common.json +167 -13
- package/package.json +2 -2
- package/src/img/svg/logo.svg +2 -2
- package/src/locales/cs-CZ/common.json +167 -13
- package/src/locales/de-DE/common.json +165 -13
- package/src/locales/es-ES/common.json +165 -13
- package/src/locales/fr-FR/common.json +165 -13
- package/src/locales/it-IT/common.json +165 -13
- package/src/locales/ja-JP/common.json +164 -13
- package/src/locales/ko-KR/common.json +164 -13
- package/src/locales/lt-LT/common.json +167 -13
- package/src/locales/nl-NL/common.json +165 -13
- package/src/locales/pl-PL/common.json +167 -13
- package/src/locales/pt-BR/common.json +165 -13
- package/src/locales/ro-RO/common.json +166 -13
- package/src/locales/ru-RU/common.json +167 -13
- package/src/locales/sl-SI/common.json +167 -13
- package/src/locales/sv-SE/common.json +165 -13
- package/src/locales/uk-UA/common.json +167 -13
- package/src/react-extension/ExtAuthenticationLogin.js +1 -0
- package/src/react-extension/components/Administration/DisplayHealthcheckAdministration/DisplayHealthcheckAdministration.js +14 -23
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.js +2 -1
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.test.data.js +5 -0
- package/src/react-extension/components/UserSetting/DisplayUserTheme/DisplayUserTheme.test.js +13 -1
- package/src/react-extension/contexts/ResourceWorkspaceContext.js +3 -1
- package/src/react-extension/contexts/ResourceWorkspaceContext.test.js +8 -0
- package/src/react-web-integration/lib/Dom/DomUtils.js +1 -1
- package/src/react-web-integration/lib/Dom/DomUtils.test.js +19 -0
- package/src/react-web-integration/lib/InForm/InFormCallToActionField.js +5 -1
- package/src/react-web-integration/lib/InForm/InFormCallToActionField.test.js +39 -0
- package/src/react-web-integration/lib/InForm/InFormManager.js +36 -13
- package/src/react-web-integration/lib/InForm/InformManager.test.js +255 -6
- package/src/react-web-integration/lib/InForm/InformManager.test.page.js +7 -7
- package/src/react-web-integration/lib/InForm/ScrapingDictionary.js +1 -1
- package/src/react-web-integration/services/Scraping/FieldScraperService.js +7 -4
- package/src/react-web-integration/services/Scraping/LabelIndex.js +86 -0
- package/src/react-web-integration/services/Scraping/LabelIndex.test.js +111 -0
- package/src/react-web-integration/services/Scraping/LabelScraperService.js +18 -14
- package/src/react-web-integration/services/Scraping/LabelScraperService.test.js +5 -5
- package/src/react-web-integration/services/Scraping/PageScraperHelpers.js +21 -5
- package/src/react-web-integration/services/Scraping/PageScraperHelpers.test.js +116 -0
- package/src/react-web-integration/services/Scraping/PageScraperService.js +6 -3
- package/src/react-web-integration/services/classification/FieldClassificationService.js +46 -40
- package/src/react-web-integration/services/classification/FieldClassificationService.test.data.js +3 -2
- package/src/react-web-integration/services/classification/FieldClassificationService.test.js +72 -0
- package/src/react-web-integration/services/classification/FieldFeatureService.js +12 -14
- package/src/react-web-integration/services/classification/FieldFeatureService.test.js +25 -11
- package/src/react-web-integration/services/classification/FieldsRationalizationService.js +1 -1
- package/src/react-web-integration/services/classification/KeywordMatchingService.js +18 -4
- package/src/react-web-integration/services/classification/KeywordMatchingService.test.js +35 -0
- package/src/react-web-integration/services/classification/KeywordsDictionary.js +21 -1
- package/src/react-web-integration/services/classification/PasswordRoleResolutionService.js +2 -2
- package/src/react-web-integration/services/classification/SegmentedOtpResolutionService.js +2 -2
- package/src/shared/utils/filterUtils.js +3 -2
- package/src/shared/utils/filterUtils.test.js +15 -0
- package/build/css/help.min.css +0 -9
- package/build/css/public.min.css +0 -8
- package/build/css/themes/default/api_cloud.min.css +0 -8
- package/build/css/themes/default/api_reports.min.css +0 -9
- package/build/css/themes/default/api_webinstaller.min.css +0 -9
- package/build/css/themes/layette/api_reports.min.css +0 -9
- package/build/css/themes/midgar/api_reports.min.css +0 -9
- package/build/css/themes/sakura/api_reports.min.css +0 -9
- package/build/css/themes/solarized_dark/api_reports.min.css +0 -9
- package/build/css/themes/solarized_light/api_reports.min.css +0 -9
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import ShadowDomQueryService from "../ShadowDom/ShadowDomQueryService";
|
|
16
16
|
import PageScraperHelpers from "./PageScraperHelpers";
|
|
17
|
+
import LabelIndex from "./LabelIndex";
|
|
17
18
|
import TextNormalizer from "../../lib/InForm/TextNormalizer";
|
|
18
19
|
import {
|
|
19
20
|
LABEL_TIERS,
|
|
@@ -40,15 +41,16 @@ class LabelScraperService {
|
|
|
40
41
|
* Elect the field's label and capture its ARIA state, writing both back onto the payload.
|
|
41
42
|
* @param {FieldScraping} fieldScraping The per-field payload: reads `element` (and `inputDescription.placeholder`),
|
|
42
43
|
* writes `label` ({text, source}) and `ariaState`.
|
|
44
|
+
* @param {LabelIndex} [labelIndex] The label index of the scrape.
|
|
43
45
|
* @returns {FieldScraping} The same payload, for call-site chaining.
|
|
44
46
|
*/
|
|
45
|
-
static enrich(fieldScraping) {
|
|
47
|
+
static enrich(fieldScraping, labelIndex = new LabelIndex()) {
|
|
46
48
|
const element = fieldScraping?.element;
|
|
47
49
|
if (!ShadowDomQueryService.isElement(element)) {
|
|
48
50
|
return fieldScraping;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
fieldScraping.label = LabelScraperService._electLabel(fieldScraping);
|
|
53
|
+
fieldScraping.label = LabelScraperService._electLabel(fieldScraping, labelIndex);
|
|
52
54
|
fieldScraping.ariaState = LabelScraperService._ariaState(element);
|
|
53
55
|
|
|
54
56
|
return fieldScraping;
|
|
@@ -59,12 +61,13 @@ class LabelScraperService {
|
|
|
59
61
|
* yields non-empty, cleaned text together with the tier that produced it.
|
|
60
62
|
* @private
|
|
61
63
|
* @param {FieldScraping} fieldScraping The per-field payload.
|
|
64
|
+
* @param {LabelIndex} labelIndex The label index of the scrape.
|
|
62
65
|
* @returns {{text: string, source: ?string}} The elected label, or `{text: "", source: null}` when
|
|
63
66
|
* every tier came up empty.
|
|
64
67
|
*/
|
|
65
|
-
static _electLabel(fieldScraping) {
|
|
68
|
+
static _electLabel(fieldScraping, labelIndex) {
|
|
66
69
|
for (const tier of LABEL_TIERS) {
|
|
67
|
-
const text = LabelScraperService._clean(LabelScraperService[tier](fieldScraping));
|
|
70
|
+
const text = LabelScraperService._clean(LabelScraperService[tier](fieldScraping, labelIndex));
|
|
68
71
|
if (text) {
|
|
69
72
|
return { text, source: tier };
|
|
70
73
|
}
|
|
@@ -79,19 +82,19 @@ class LabelScraperService {
|
|
|
79
82
|
* ancestor climbed across shadow boundaries.
|
|
80
83
|
* @private
|
|
81
84
|
* @param {FieldScraping} fieldScraping The per-field payload.
|
|
85
|
+
* @param {LabelIndex} [labelIndex] The label index of the scrape.
|
|
82
86
|
* @returns {string} The raw label text, or "" when no explicit association exists.
|
|
83
87
|
*/
|
|
84
|
-
static _explicit(fieldScraping) {
|
|
88
|
+
static _explicit(fieldScraping, labelIndex = new LabelIndex()) {
|
|
85
89
|
const element = fieldScraping.element;
|
|
86
90
|
|
|
87
91
|
// Native association. `.labels` covers both `for=` and wrapping labels in the light DOM. Guarded
|
|
88
92
|
// (like every non-final source below) so an empty native `<label>` falls through to the next
|
|
89
|
-
// source rather than short-circuiting the tier with whitespace.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
.join(" ");
|
|
93
|
+
// source rather than short-circuiting the tier with whitespace. Read from the index, since the
|
|
94
|
+
// first access to `element.labels` scans the whole root.
|
|
95
|
+
const nativeLabels = labelIndex.labelsOf(element);
|
|
96
|
+
if (nativeLabels.length > 0) {
|
|
97
|
+
const text = nativeLabels.map((label) => PageScraperHelpers.textWithoutFields(label)).join(" ");
|
|
95
98
|
if (LabelScraperService._hasText(text)) {
|
|
96
99
|
return text;
|
|
97
100
|
}
|
|
@@ -101,7 +104,7 @@ class LabelScraperService {
|
|
|
101
104
|
// across a shadow boundary (nor onto the live document for a detached field). `.labels` is often
|
|
102
105
|
// empty here, hence the fallback.
|
|
103
106
|
const root = LabelScraperService._root(element);
|
|
104
|
-
const forLabel = LabelScraperService._labelForField(root, element);
|
|
107
|
+
const forLabel = LabelScraperService._labelForField(root, element, labelIndex);
|
|
105
108
|
if (forLabel) {
|
|
106
109
|
const text = PageScraperHelpers.textWithoutFields(forLabel);
|
|
107
110
|
if (LabelScraperService._hasText(text)) {
|
|
@@ -124,15 +127,16 @@ class LabelScraperService {
|
|
|
124
127
|
* @private
|
|
125
128
|
* @param {Document|ShadowRoot} root The field's root node.
|
|
126
129
|
* @param {Element} element The field element.
|
|
130
|
+
* @param {LabelIndex} labelIndex The label index of the scrape.
|
|
127
131
|
* @returns {Element} The matching label, or `null`.
|
|
128
132
|
*/
|
|
129
|
-
static _labelForField(root, element) {
|
|
133
|
+
static _labelForField(root, element, labelIndex) {
|
|
130
134
|
for (const attr of LABEL_FOR_ATTRS) {
|
|
131
135
|
const value = element.getAttribute(attr);
|
|
132
136
|
if (!value) {
|
|
133
137
|
continue;
|
|
134
138
|
}
|
|
135
|
-
const match =
|
|
139
|
+
const match = labelIndex.labelFor(root, value);
|
|
136
140
|
if (match) {
|
|
137
141
|
return match;
|
|
138
142
|
}
|
|
@@ -16,7 +16,7 @@ import LabelScraperService from "./LabelScraperService";
|
|
|
16
16
|
import ShadowDomQueryService from "../ShadowDom/ShadowDomQueryService";
|
|
17
17
|
import ShadowRootCacheService from "../ShadowDom/ShadowRootCacheService";
|
|
18
18
|
import ShadowMutationObserverService from "../ShadowDom/ShadowMutationObserverService";
|
|
19
|
-
import { MAX_SCRAPED_STRING_LENGTH } from "../../lib/InForm/ScrapingDictionary";
|
|
19
|
+
import { MAX_LABEL_ANCESTOR_HOPS, MAX_SCRAPED_STRING_LENGTH } from "../../lib/InForm/ScrapingDictionary";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Build a minimal FieldScraping payload around a field element.
|
|
@@ -625,8 +625,8 @@ describe("LabelScraperService", () => {
|
|
|
625
625
|
it("should elect a qualifying ancestor sitting at the last examined hop", () => {
|
|
626
626
|
expect.assertions(1);
|
|
627
627
|
|
|
628
|
-
// The labelled div is the
|
|
629
|
-
const payload = fieldScraping(nestedAncestorLabel(
|
|
628
|
+
// The labelled div is the last ancestor within the cap; everything between is empty.
|
|
629
|
+
const payload = fieldScraping(nestedAncestorLabel(MAX_LABEL_ANCESTOR_HOPS, "Deep"));
|
|
630
630
|
|
|
631
631
|
LabelScraperService.enrich(payload);
|
|
632
632
|
|
|
@@ -636,8 +636,8 @@ describe("LabelScraperService", () => {
|
|
|
636
636
|
it("should not elect a qualifying ancestor one hop past the cap", () => {
|
|
637
637
|
expect.assertions(1);
|
|
638
638
|
|
|
639
|
-
// The labelled div is the
|
|
640
|
-
const payload = fieldScraping(nestedAncestorLabel(
|
|
639
|
+
// The labelled div is the first ancestor past the cap and must never be reached.
|
|
640
|
+
const payload = fieldScraping(nestedAncestorLabel(MAX_LABEL_ANCESTOR_HOPS + 1, "TooDeep"));
|
|
641
641
|
|
|
642
642
|
LabelScraperService.enrich(payload);
|
|
643
643
|
|
|
@@ -28,20 +28,36 @@ class PageScraperHelpers {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Returns the text content of the element (without the text of its form controls and buttons).
|
|
31
|
-
* NOTE: It
|
|
31
|
+
* NOTE: It reads the live DOM through a range and never clones it: a clone owned by the page document
|
|
32
|
+
* may load its resources (e.g. an `<img>` re-requesting a CAPTCHA) and upgrades its custom elements.
|
|
32
33
|
*
|
|
33
34
|
* @param {Element} element The candidate label element.
|
|
34
35
|
* @returns {string} The text without form controls and buttons.
|
|
35
36
|
*/
|
|
36
37
|
static textWithoutFields(element) {
|
|
37
|
-
const
|
|
38
|
+
const fields = element.querySelectorAll(LABEL_TEXT_STRIP_SELECTOR);
|
|
39
|
+
if (fields.length === 0) {
|
|
40
|
+
return element.textContent;
|
|
41
|
+
}
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
// Concatenate the text found between the stripped controls.
|
|
44
|
+
const range = element.ownerDocument.createRange();
|
|
45
|
+
range.setStart(element, 0);
|
|
46
|
+
let text = "";
|
|
47
|
+
let previous = null;
|
|
40
48
|
for (const field of fields) {
|
|
41
|
-
|
|
49
|
+
// Fields are in document order: a control nested in an already stripped one is skipped with it.
|
|
50
|
+
if (previous?.contains(field)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
range.setEndBefore(field);
|
|
54
|
+
text += range.toString();
|
|
55
|
+
range.setStartAfter(field);
|
|
56
|
+
previous = field;
|
|
42
57
|
}
|
|
58
|
+
range.setEnd(element, element.childNodes.length);
|
|
43
59
|
|
|
44
|
-
return
|
|
60
|
+
return text + range.toString();
|
|
45
61
|
}
|
|
46
62
|
}
|
|
47
63
|
|
|
@@ -116,5 +116,121 @@ describe("PageScraperHelpers", () => {
|
|
|
116
116
|
expect(label.querySelector("input")).not.toBeNull();
|
|
117
117
|
expect(label.querySelector("button")).not.toBeNull();
|
|
118
118
|
});
|
|
119
|
+
|
|
120
|
+
it("should strip the whole subtree of a nested button", () => {
|
|
121
|
+
expect.assertions(1);
|
|
122
|
+
|
|
123
|
+
document.body.innerHTML = "<label>Email<button><span>Show</span><b>more</b></button></label>";
|
|
124
|
+
|
|
125
|
+
expect(PageScraperHelpers.textWithoutFields(document.querySelector("label"))).toEqual("Email");
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("should strip controls nested in an already stripped control only once", () => {
|
|
129
|
+
expect.assertions(1);
|
|
130
|
+
|
|
131
|
+
// Built with the DOM API: the HTML parser would close the outer button on the nested one.
|
|
132
|
+
document.body.innerHTML = "<div>Before <button>Outer <span></span></button> middle <input/> after</div>";
|
|
133
|
+
const innerButton = document.createElement("button");
|
|
134
|
+
innerButton.textContent = "Inner";
|
|
135
|
+
document.querySelector("span").appendChild(innerButton);
|
|
136
|
+
const select = document.createElement("select");
|
|
137
|
+
select.appendChild(document.createElement("option")).textContent = "X";
|
|
138
|
+
document.querySelector("button").appendChild(select);
|
|
139
|
+
|
|
140
|
+
expect(PageScraperHelpers.textWithoutFields(document.querySelector("div"))).toEqual("Before middle after");
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("should keep the text located after the last stripped control, including in nested elements", () => {
|
|
144
|
+
expect.assertions(1);
|
|
145
|
+
|
|
146
|
+
document.body.innerHTML = "<div><span>Code <input/> hint</span><em> (6 digits)</em></div>";
|
|
147
|
+
|
|
148
|
+
expect(PageScraperHelpers.textWithoutFields(document.querySelector("div"))).toEqual("Code hint (6 digits)");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("should not change the page selection", () => {
|
|
152
|
+
expect.assertions(1);
|
|
153
|
+
|
|
154
|
+
document.body.innerHTML = "<p id='p'>Selected text</p><label>Email<input/></label>";
|
|
155
|
+
const selection = document.getSelection();
|
|
156
|
+
selection.selectAllChildren(document.getElementById("p"));
|
|
157
|
+
const selectedBefore = selection.toString();
|
|
158
|
+
|
|
159
|
+
PageScraperHelpers.textWithoutFields(document.querySelector("label"));
|
|
160
|
+
|
|
161
|
+
expect(document.getSelection().toString()).toEqual(selectedBefore);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("should keep the text of the element itself even when it matches a stripped control", () => {
|
|
165
|
+
expect.assertions(1);
|
|
166
|
+
|
|
167
|
+
document.body.innerHTML = "<button>Sign <span>in</span></button>";
|
|
168
|
+
|
|
169
|
+
expect(PageScraperHelpers.textWithoutFields(document.querySelector("button"))).toEqual("Sign in");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("should ignore comments and keep nested script and style text like textContent", () => {
|
|
173
|
+
expect.assertions(1);
|
|
174
|
+
|
|
175
|
+
document.body.innerHTML = "<div>Email<!-- hidden --><style>.a{}</style><script>var a;</script></div>";
|
|
176
|
+
|
|
177
|
+
expect(PageScraperHelpers.textWithoutFields(document.querySelector("div"))).toEqual("Email.a{}var a;");
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("should not clone the element, so its images are not requested again (e.g. a CAPTCHA)", () => {
|
|
181
|
+
expect.assertions(3);
|
|
182
|
+
|
|
183
|
+
document.body.innerHTML =
|
|
184
|
+
"<div>Enter the code <img src='/login/captcha/key?123' alt='captcha'/><input name='captcha'/></div>";
|
|
185
|
+
const cloneNodeSpy = jest.spyOn(Node.prototype, "cloneNode");
|
|
186
|
+
const importNodeSpy = jest.spyOn(Document.prototype, "importNode");
|
|
187
|
+
|
|
188
|
+
const text = PageScraperHelpers.textWithoutFields(document.querySelector("div"));
|
|
189
|
+
|
|
190
|
+
expect(text).toEqual("Enter the code ");
|
|
191
|
+
expect(cloneNodeSpy).not.toHaveBeenCalled();
|
|
192
|
+
expect(importNodeSpy).not.toHaveBeenCalled();
|
|
193
|
+
|
|
194
|
+
cloneNodeSpy.mockRestore();
|
|
195
|
+
importNodeSpy.mockRestore();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("should extract the text of an element living in a same-origin iframe", () => {
|
|
199
|
+
expect.assertions(1);
|
|
200
|
+
|
|
201
|
+
const iframe = document.createElement("iframe");
|
|
202
|
+
document.body.appendChild(iframe);
|
|
203
|
+
const iframeDocument = iframe.contentDocument;
|
|
204
|
+
iframeDocument.body.innerHTML = "<label>Password<input type='password'/><button>Show</button></label>";
|
|
205
|
+
|
|
206
|
+
expect(PageScraperHelpers.textWithoutFields(iframeDocument.querySelector("label"))).toEqual("Password");
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it("should return the same text as the former clone-based implementation", () => {
|
|
210
|
+
const legacyTextWithoutFields = (element) => {
|
|
211
|
+
const clone = element.cloneNode(true);
|
|
212
|
+
clone.querySelectorAll("input, textarea, select, button").forEach((field) => field.remove());
|
|
213
|
+
return clone.textContent;
|
|
214
|
+
};
|
|
215
|
+
const fixtures = [
|
|
216
|
+
"<label>Email</label>",
|
|
217
|
+
"<label>Email<input value='user@passbolt.com'/></label>",
|
|
218
|
+
"<label>Message<textarea>my private note</textarea><select><option>FR</option></select></label>",
|
|
219
|
+
"<div>First name <input/> <span>required</span></div>",
|
|
220
|
+
"<div><span>User<em>name</em></span><button><span>Go</span></button> <i>(email)</i></div>",
|
|
221
|
+
"<table><tbody><tr><td>Code <img src='captcha.jpg'/><input/><a href='#'>Reload</a></td></tr></tbody></table>",
|
|
222
|
+
"<li>A<div>B<div>C<input/>D</div>E</div>F</li>",
|
|
223
|
+
"<div>Email<!-- note --><style>.a{}</style></div>",
|
|
224
|
+
"<button>Sign <span>in</span></button>",
|
|
225
|
+
];
|
|
226
|
+
expect.assertions(fixtures.length);
|
|
227
|
+
|
|
228
|
+
for (const fixture of fixtures) {
|
|
229
|
+
// eslint-disable-next-line no-unsanitized/property
|
|
230
|
+
document.body.innerHTML = fixture;
|
|
231
|
+
const element = document.body.firstElementChild;
|
|
232
|
+
expect(PageScraperHelpers.textWithoutFields(element)).toEqual(legacyTextWithoutFields(element));
|
|
233
|
+
}
|
|
234
|
+
});
|
|
119
235
|
});
|
|
120
236
|
});
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import FormScraperService from "../DomExtraction/FormScraperService";
|
|
16
16
|
import FieldScraperService from "./FieldScraperService";
|
|
17
17
|
import ScrapingIdentityService from "./ScrapingIdentityService";
|
|
18
|
+
import LabelIndex from "./LabelIndex";
|
|
18
19
|
import ShadowDomQueryService from "../ShadowDom/ShadowDomQueryService";
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -31,9 +32,10 @@ class PageScraperService {
|
|
|
31
32
|
const skeletons = formElements ?? [];
|
|
32
33
|
const forms = {};
|
|
33
34
|
const fields = [];
|
|
35
|
+
const labelIndex = new LabelIndex();
|
|
34
36
|
|
|
35
37
|
for (const skeleton of skeletons) {
|
|
36
|
-
const scraped = PageScraperService._scrapeForm(skeleton);
|
|
38
|
+
const scraped = PageScraperService._scrapeForm(skeleton, labelIndex);
|
|
37
39
|
if (scraped) {
|
|
38
40
|
forms[scraped.form.formId] = scraped.form;
|
|
39
41
|
fields.push(...scraped.fields);
|
|
@@ -55,10 +57,11 @@ class PageScraperService {
|
|
|
55
57
|
* {@link FormScraperService} and each field to {@link FieldScraperService}, and tally the `fieldTypes` histogram.
|
|
56
58
|
* @private
|
|
57
59
|
* @param {object} skeleton The skeleton container entry.
|
|
60
|
+
* @param {LabelIndex} labelIndex The `<label for>` index of the scrape.
|
|
58
61
|
* @returns {{form: FormScraping, fields: FieldScraping[]}} The form and its fields, or `null` when the
|
|
59
62
|
* container is not an element.
|
|
60
63
|
*/
|
|
61
|
-
static _scrapeForm(skeleton) {
|
|
64
|
+
static _scrapeForm(skeleton, labelIndex) {
|
|
62
65
|
const containerElement = skeleton?.containerElement;
|
|
63
66
|
if (!ShadowDomQueryService.isElement(containerElement)) {
|
|
64
67
|
return null;
|
|
@@ -74,7 +77,7 @@ class PageScraperService {
|
|
|
74
77
|
continue;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
|
-
const fieldRecord = FieldScraperService.scrape(element, formId);
|
|
80
|
+
const fieldRecord = FieldScraperService.scrape(element, formId, labelIndex);
|
|
78
81
|
fields.push(fieldRecord);
|
|
79
82
|
PageScraperService._incrementFieldTypeCount(form, fieldRecord.type);
|
|
80
83
|
}
|
|
@@ -17,7 +17,13 @@ import KeywordMatchingService from "./KeywordMatchingService";
|
|
|
17
17
|
import SawfClassificationService from "./SawfClassificationService";
|
|
18
18
|
import FieldFeatureService from "./FieldFeatureService";
|
|
19
19
|
import { FieldRole, Tier } from "./Taxonomy";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
Keywords,
|
|
22
|
+
NON_CREDENTIAL_INPUT_TYPES,
|
|
23
|
+
MIN_OTP_SEGMENTS,
|
|
24
|
+
MAX_OTP_SEGMENTS,
|
|
25
|
+
NON_CREDENTIAL_INPUT_ROLES,
|
|
26
|
+
} from "./KeywordsDictionary";
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
29
|
* A rough e-mail shape, used to detect an email field from its placeholder text.
|
|
@@ -57,18 +63,15 @@ class FieldClassificationService {
|
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
/**
|
|
60
|
-
* Normalizes the texts and declared roles.
|
|
66
|
+
* Normalizes the texts, one per attribute, and the declared roles.
|
|
61
67
|
* @param {FieldScraping} field The field.
|
|
62
|
-
* @returns {{
|
|
68
|
+
* @returns {{strongTexts: string[], weakTexts: string[], sawfRole: string, acRole: string|null}} The signals.
|
|
63
69
|
*/
|
|
64
70
|
static signals(field) {
|
|
71
|
+
const normalizeEach = (values) => values.filter(Boolean).map((value) => TextNormalizer.normalizeForMatch(value));
|
|
65
72
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
),
|
|
69
|
-
weakText: TextNormalizer.normalizeForMatch(
|
|
70
|
-
[field.attributes?.name, field.attributes?.id, field.inputDescription?.placeholder].filter(Boolean).join(" "),
|
|
71
|
-
),
|
|
73
|
+
strongTexts: normalizeEach([field.label?.text, field.inputDescription?.ariaLabel]),
|
|
74
|
+
weakTexts: normalizeEach([field.attributes?.name, field.attributes?.id, field.inputDescription?.placeholder]),
|
|
72
75
|
sawfRole: SawfClassificationService.sawfFieldRole(field.dataFormType),
|
|
73
76
|
acRole: KeywordMatchingService.roleFromAutocomplete(field.autoComplete),
|
|
74
77
|
};
|
|
@@ -80,7 +83,10 @@ class FieldClassificationService {
|
|
|
80
83
|
* @returns {{role: string, tier: number}|null} OTHER or null.
|
|
81
84
|
*/
|
|
82
85
|
static hardExclude(field) {
|
|
83
|
-
if (
|
|
86
|
+
if (
|
|
87
|
+
field.tagName === "INPUT" &&
|
|
88
|
+
(NON_CREDENTIAL_INPUT_TYPES.has(field.type) || NON_CREDENTIAL_INPUT_ROLES.has(field.attributes.role))
|
|
89
|
+
) {
|
|
84
90
|
return { role: FieldRole.OTHER, tier: Tier.NONE };
|
|
85
91
|
}
|
|
86
92
|
return null;
|
|
@@ -89,13 +95,13 @@ class FieldClassificationService {
|
|
|
89
95
|
/**
|
|
90
96
|
* Returns OTHER when a recovery or backup keyword is found.
|
|
91
97
|
* @param {FieldScraping} field The field.
|
|
92
|
-
* @param {{
|
|
98
|
+
* @param {{strongTexts: string[], weakTexts: string[]}} signals The signals.
|
|
93
99
|
* @returns {{role: string, tier: number}|null} OTHER or null.
|
|
94
100
|
*/
|
|
95
|
-
static recoveryVeto(field, {
|
|
101
|
+
static recoveryVeto(field, { strongTexts, weakTexts }) {
|
|
96
102
|
if (
|
|
97
|
-
KeywordMatchingService.matchesAny(
|
|
98
|
-
KeywordMatchingService.matchesAny(
|
|
103
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.RECOVERY) ||
|
|
104
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.RECOVERY)
|
|
99
105
|
) {
|
|
100
106
|
return { role: FieldRole.OTHER, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
101
107
|
}
|
|
@@ -105,10 +111,10 @@ class FieldClassificationService {
|
|
|
105
111
|
/**
|
|
106
112
|
* Returns TOTP when declared by data-form-type or autocomplete, or when a TOTP keyword is found.
|
|
107
113
|
* @param {FieldScraping} field The field.
|
|
108
|
-
* @param {{
|
|
114
|
+
* @param {{strongTexts: string[], weakTexts: string[], sawfRole: string, acRole: string|null}} signals The signals.
|
|
109
115
|
* @returns {{role: string, tier: number}|null} A TOTP decision, or null.
|
|
110
116
|
*/
|
|
111
|
-
static totp(field, {
|
|
117
|
+
static totp(field, { strongTexts, weakTexts, sawfRole, acRole }) {
|
|
112
118
|
if (sawfRole === FieldRole.TOTP) {
|
|
113
119
|
return { role: FieldRole.TOTP, tier: Tier.SAWF };
|
|
114
120
|
}
|
|
@@ -116,15 +122,15 @@ class FieldClassificationService {
|
|
|
116
122
|
return { role: FieldRole.TOTP, tier: Tier.AUTOCOMPLETE };
|
|
117
123
|
}
|
|
118
124
|
if (
|
|
119
|
-
KeywordMatchingService.matchesAny(
|
|
120
|
-
KeywordMatchingService.matchesAny(
|
|
125
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.TOTP) ||
|
|
126
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.TOTP)
|
|
121
127
|
) {
|
|
122
128
|
return { role: FieldRole.TOTP, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
123
129
|
}
|
|
124
130
|
// An ambiguous token (code, pin) only counts as TOTP when the maxLength or a numeric input hint confirms it.
|
|
125
131
|
if (
|
|
126
|
-
(KeywordMatchingService.matchesAny(
|
|
127
|
-
KeywordMatchingService.matchesAny(
|
|
132
|
+
(KeywordMatchingService.matchesAny(strongTexts, Keywords.TOTP_AMBIGUOUS) ||
|
|
133
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.TOTP_AMBIGUOUS)) &&
|
|
128
134
|
FieldClassificationService.corroboratesSingleOtp(field)
|
|
129
135
|
) {
|
|
130
136
|
return { role: FieldRole.TOTP, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
@@ -190,13 +196,13 @@ class FieldClassificationService {
|
|
|
190
196
|
* them as a username. Runs after the declared (SAWF / autocomplete) and native `type=email|password`
|
|
191
197
|
* tiers, so real credentials still win, and ignores `class` so widget class names never trigger it.
|
|
192
198
|
* @param {FieldScraping} field The field.
|
|
193
|
-
* @param {{
|
|
199
|
+
* @param {{strongTexts: string[], weakTexts: string[]}} signals The signals.
|
|
194
200
|
* @returns {({role: string, tier: number}|null)} OTHER, or null to continue.
|
|
195
201
|
*/
|
|
196
|
-
static ignoreVeto(field, {
|
|
202
|
+
static ignoreVeto(field, { strongTexts, weakTexts }) {
|
|
197
203
|
if (
|
|
198
|
-
KeywordMatchingService.matchesAny(
|
|
199
|
-
KeywordMatchingService.matchesAny(
|
|
204
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.FIELD_IGNORE) ||
|
|
205
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.FIELD_IGNORE)
|
|
200
206
|
) {
|
|
201
207
|
return { role: FieldRole.OTHER, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
202
208
|
}
|
|
@@ -208,21 +214,21 @@ class FieldClassificationService {
|
|
|
208
214
|
* The placeholder is only evaluated for EMAIL.
|
|
209
215
|
* Returns null when the label describes a password together with an email or identifier.
|
|
210
216
|
* @param {FieldScraping} field The field.
|
|
211
|
-
* @param {{
|
|
217
|
+
* @param {{strongTexts: string[]}} signals The signals.
|
|
212
218
|
* @returns {{role: string, tier: number}|null} A label decision, or null.
|
|
213
219
|
*/
|
|
214
|
-
static byExplicitLabel(field, {
|
|
220
|
+
static byExplicitLabel(field, { strongTexts }) {
|
|
215
221
|
const isEmail =
|
|
216
|
-
KeywordMatchingService.matchesAny(
|
|
222
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.EMAIL) ||
|
|
217
223
|
EMAIL_PLACEHOLDER.test(field.inputDescription?.placeholder || "");
|
|
218
224
|
|
|
219
225
|
const isPassword =
|
|
220
|
-
KeywordMatchingService.matchesAny(
|
|
221
|
-
!KeywordMatchingService.matchesAny(
|
|
226
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.PASSWORD) &&
|
|
227
|
+
!KeywordMatchingService.matchesAny(strongTexts, Keywords.PASSWORD_EXCLUDE);
|
|
222
228
|
|
|
223
229
|
const isIdentifier =
|
|
224
|
-
KeywordMatchingService.matchesAny(
|
|
225
|
-
!KeywordMatchingService.matchesAny(
|
|
230
|
+
KeywordMatchingService.matchesAny(strongTexts, Keywords.IDENTIFIER) &&
|
|
231
|
+
!KeywordMatchingService.matchesAny(strongTexts, Keywords.ACCOUNT_NUMBER);
|
|
226
232
|
|
|
227
233
|
if (isEmail && !isPassword) {
|
|
228
234
|
return { role: FieldRole.EMAIL, tier: Tier.EXPLICIT_LABEL };
|
|
@@ -242,27 +248,27 @@ class FieldClassificationService {
|
|
|
242
248
|
/**
|
|
243
249
|
* Returns the role found in the name, id and placeholder keywords.
|
|
244
250
|
* @param {FieldScraping} field The field.
|
|
245
|
-
* @param {{
|
|
251
|
+
* @param {{weakTexts: string[]}} signals The signals.
|
|
246
252
|
* @returns {{role: string, tier: number}|null} A keyword decision, or null.
|
|
247
253
|
*/
|
|
248
|
-
static byAttributeKeyword(field, {
|
|
254
|
+
static byAttributeKeyword(field, { weakTexts }) {
|
|
249
255
|
if (
|
|
250
|
-
KeywordMatchingService.matchesAny(
|
|
251
|
-
!KeywordMatchingService.matchesAny(
|
|
256
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.EMAIL) &&
|
|
257
|
+
!KeywordMatchingService.matchesAny(weakTexts, Keywords.IDENTIFIER_EXCLUDE)
|
|
252
258
|
) {
|
|
253
259
|
return { role: FieldRole.EMAIL, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
254
260
|
}
|
|
255
261
|
if (
|
|
256
262
|
field.type === "text" &&
|
|
257
|
-
KeywordMatchingService.matchesAny(
|
|
258
|
-
!KeywordMatchingService.matchesAny(
|
|
263
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.PASSWORD) &&
|
|
264
|
+
!KeywordMatchingService.matchesAny(weakTexts, Keywords.PASSWORD_EXCLUDE)
|
|
259
265
|
) {
|
|
260
266
|
return { role: FieldRole.PASSWORD, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
261
267
|
}
|
|
262
268
|
if (
|
|
263
|
-
KeywordMatchingService.matchesAny(
|
|
264
|
-
!KeywordMatchingService.matchesAny(
|
|
265
|
-
!KeywordMatchingService.matchesAny(
|
|
269
|
+
KeywordMatchingService.matchesAny(weakTexts, Keywords.IDENTIFIER) &&
|
|
270
|
+
!KeywordMatchingService.matchesAny(weakTexts, Keywords.IDENTIFIER_EXCLUDE) &&
|
|
271
|
+
!KeywordMatchingService.matchesAny(weakTexts, Keywords.ACCOUNT_NUMBER)
|
|
266
272
|
) {
|
|
267
273
|
return { role: FieldRole.USERNAME, tier: Tier.ATTRIBUTE_KEYWORD };
|
|
268
274
|
}
|
package/src/react-web-integration/services/classification/FieldClassificationService.test.data.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Build a value-free field record for classification.
|
|
17
|
-
* @param {object} [overrides] Field overrides (flat: tagName/type/dataFormType/autoComplete/name/id/labelText/ariaLabel/placeholder/maxLength/inputMode/pattern).
|
|
17
|
+
* @param {object} [overrides] Field overrides (flat: tagName/type/dataFormType/autoComplete/name/id/labelText/ariaLabel/placeholder/maxLength/inputMode/pattern/role).
|
|
18
18
|
* @returns {object} The field record.
|
|
19
19
|
*/
|
|
20
20
|
export const defaultField = (overrides = {}) => {
|
|
@@ -31,6 +31,7 @@ export const defaultField = (overrides = {}) => {
|
|
|
31
31
|
maxLength = null,
|
|
32
32
|
inputMode = "",
|
|
33
33
|
pattern = "",
|
|
34
|
+
role = "",
|
|
34
35
|
} = overrides;
|
|
35
36
|
return {
|
|
36
37
|
fieldId: "field",
|
|
@@ -38,7 +39,7 @@ export const defaultField = (overrides = {}) => {
|
|
|
38
39
|
type,
|
|
39
40
|
dataFormType,
|
|
40
41
|
autoComplete,
|
|
41
|
-
attributes: { name, id, maxLength, inputMode, pattern },
|
|
42
|
+
attributes: { name, id, maxLength, inputMode, pattern, role },
|
|
42
43
|
label: { text: labelText },
|
|
43
44
|
inputDescription: { ariaLabel, placeholder },
|
|
44
45
|
};
|
package/src/react-web-integration/services/classification/FieldClassificationService.test.js
CHANGED
|
@@ -48,6 +48,43 @@ describe("FieldClassificationService", () => {
|
|
|
48
48
|
|
|
49
49
|
expect(decision).toStrictEqual({ role: FieldRole.USERNAME, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
50
50
|
});
|
|
51
|
+
|
|
52
|
+
it.each(["button", "checkbox", "combobox", "spinbutton", "radio", "slider"])(
|
|
53
|
+
"should hard-exclude an INPUT with non-credential role %j to OTHER at tier NONE",
|
|
54
|
+
(role) => {
|
|
55
|
+
expect.assertions(1);
|
|
56
|
+
|
|
57
|
+
const decision = FieldClassificationService.classify(defaultField({ role, name: "username" }));
|
|
58
|
+
|
|
59
|
+
expect(decision).toStrictEqual({ role: FieldRole.OTHER, tier: Tier.NONE });
|
|
60
|
+
},
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
it("should not hard-exclude an INPUT with a credential-neutral role (textbox) and let the ladder resolve it", () => {
|
|
64
|
+
expect.assertions(1);
|
|
65
|
+
|
|
66
|
+
const decision = FieldClassificationService.classify(defaultField({ role: "textbox", name: "username" }));
|
|
67
|
+
|
|
68
|
+
expect(decision).toStrictEqual({ role: FieldRole.USERNAME, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("should not hard-exclude an INPUT without a role and let the ladder resolve it", () => {
|
|
72
|
+
expect.assertions(1);
|
|
73
|
+
|
|
74
|
+
const decision = FieldClassificationService.classify(defaultField({ name: "username" }));
|
|
75
|
+
|
|
76
|
+
expect(decision).toStrictEqual({ role: FieldRole.USERNAME, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("should not hard-exclude a non-INPUT tag by the input-role rule", () => {
|
|
80
|
+
expect.assertions(1);
|
|
81
|
+
|
|
82
|
+
const decision = FieldClassificationService.classify(
|
|
83
|
+
defaultField({ tagName: "SELECT", type: "", role: "combobox", name: "username" }),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
expect(decision).toStrictEqual({ role: FieldRole.USERNAME, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
87
|
+
});
|
|
51
88
|
});
|
|
52
89
|
|
|
53
90
|
describe("recovery veto", () => {
|
|
@@ -101,6 +138,41 @@ describe("FieldClassificationService", () => {
|
|
|
101
138
|
expect(decision).toStrictEqual({ role: FieldRole.TOTP, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
102
139
|
});
|
|
103
140
|
|
|
141
|
+
it.each([
|
|
142
|
+
{ name: "fattura_acconto_10902", id: "fattura_10902" },
|
|
143
|
+
{ name: "voce_2_fattura" },
|
|
144
|
+
{ name: "10902fattura" },
|
|
145
|
+
{ id: "importo_12", placeholder: "fa riferimento alla fattura" },
|
|
146
|
+
])("should not classify %j as TOTP when 2fa only appears across a boundary", (attributes) => {
|
|
147
|
+
expect.assertions(1);
|
|
148
|
+
|
|
149
|
+
const decision = FieldClassificationService.classify(defaultField(attributes));
|
|
150
|
+
|
|
151
|
+
expect(decision.role).not.toBe(FieldRole.TOTP);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it.each([
|
|
155
|
+
{ name: "2fa" },
|
|
156
|
+
{ name: "2FA" },
|
|
157
|
+
{ id: "Field2FA" },
|
|
158
|
+
{ name: "2fa_code" },
|
|
159
|
+
{ name: "2faCode" },
|
|
160
|
+
{ name: "2facode" },
|
|
161
|
+
{ name: "user2fa" },
|
|
162
|
+
{ labelText: "2FA code" },
|
|
163
|
+
{ name: "twofa" },
|
|
164
|
+
{ name: "otpcode" },
|
|
165
|
+
{ name: "mfa_token" },
|
|
166
|
+
{ name: "one_time_code" },
|
|
167
|
+
{ name: "twoFactorCode" },
|
|
168
|
+
])("should still classify %j as TOTP at tier ATTRIBUTE_KEYWORD", (attributes) => {
|
|
169
|
+
expect.assertions(1);
|
|
170
|
+
|
|
171
|
+
const decision = FieldClassificationService.classify(defaultField(attributes));
|
|
172
|
+
|
|
173
|
+
expect(decision).toStrictEqual({ role: FieldRole.TOTP, tier: Tier.ATTRIBUTE_KEYWORD });
|
|
174
|
+
});
|
|
175
|
+
|
|
104
176
|
it("should classify a field whose label is a TOTP keyword as TOTP at tier ATTRIBUTE_KEYWORD", () => {
|
|
105
177
|
expect.assertions(1);
|
|
106
178
|
|