@wallarm-org/design-system 0.88.1-rc-fix-status-code-zero-value.1 → 0.88.1-rc-fix-status-code-zero-value.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/dist/components/FilterInput/lib/statusCode/createStatusCodeNormalizer.d.ts +2 -3
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeNormalizer.js +0 -2
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeSerializer.d.ts +2 -3
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeSerializer.js +0 -2
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeSuggestions.d.ts +3 -3
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeSuggestions.js +2 -2
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeValidator.d.ts +3 -6
- package/dist/components/FilterInput/lib/statusCode/createStatusCodeValidator.js +1 -2
- package/dist/components/FilterInput/lib/statusCode/utils/canonicalize.d.ts +2 -1
- package/dist/components/FilterInput/lib/statusCode/utils/constants.d.ts +5 -9
- package/dist/components/FilterInput/lib/statusCode/utils/constants.js +2 -2
- package/dist/components/FilterInput/lib/statusCode/utils/index.d.ts +1 -1
- package/dist/components/FilterInput/lib/statusCode/utils/index.js +1 -1
- package/dist/components/FilterInput/lib/statusCode/utils/makeMask.d.ts +7 -5
- package/dist/components/FilterInput/lib/statusCode/utils/makeMask.js +1 -2
- package/dist/metadata/components.json +1 -1
- package/package.json +1 -1
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
* - "2" → "2XX"
|
|
5
5
|
* - "22" → "22X"
|
|
6
6
|
* - "2x" → "2XX"
|
|
7
|
+
* - "0" → "0XX" (Wallarm's "no response" class)
|
|
7
8
|
* - "222", "4XX", "40X" → unchanged (already 3 chars)
|
|
8
|
-
* Leaves anything unrecognised alone so `validate` can still flag it.
|
|
9
|
-
* `NO_RESPONSE_CODE` sentinel (`"0"`) is a concrete value, not a partial class,
|
|
10
|
-
* so it is passed through as-is rather than padded to `"0XX"`.
|
|
9
|
+
* Leaves anything unrecognised alone so `validate` can still flag it.
|
|
11
10
|
*/
|
|
12
11
|
export declare const createStatusCodeNormalizer: () => ((value: string | number | boolean) => string | number | boolean);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { NO_RESPONSE_CODE } from "./utils/constants.js";
|
|
2
1
|
const createStatusCodeNormalizer = ()=>(value)=>{
|
|
3
2
|
if ('string' != typeof value && 'number' != typeof value) return value;
|
|
4
3
|
const s = String(value).toUpperCase();
|
|
5
|
-
if (s === NO_RESPONSE_CODE) return s;
|
|
6
4
|
if (!/^\d[0-9X]{0,2}$/.test(s)) return value;
|
|
7
5
|
if (1 === s.length) return `${s}XX`;
|
|
8
6
|
if (2 === s.length) return `${s}X`;
|
|
@@ -8,11 +8,10 @@
|
|
|
8
8
|
* "222" → "222"
|
|
9
9
|
* "4XX" → "4"
|
|
10
10
|
* "40X" → "40"
|
|
11
|
+
* "0XX" → "0" (Wallarm's "no response" class)
|
|
11
12
|
*
|
|
12
13
|
* Anything that isn't a status-code-shaped string (e.g. a number, boolean,
|
|
13
14
|
* or freeform text) is returned unchanged so invalid committed values still
|
|
14
|
-
* surface in the backend payload for the parser to reject.
|
|
15
|
-
* `NO_RESPONSE_CODE` sentinel (`"0"`) carries no mask placeholder, so it is
|
|
16
|
-
* passed through verbatim.
|
|
15
|
+
* surface in the backend payload for the parser to reject.
|
|
17
16
|
*/
|
|
18
17
|
export declare const createStatusCodeSerializer: () => ((value: string | number | boolean) => string | number | boolean);
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { NO_RESPONSE_CODE } from "./utils/constants.js";
|
|
2
1
|
const createStatusCodeSerializer = ()=>(value)=>{
|
|
3
2
|
if ('string' != typeof value) return value;
|
|
4
|
-
if (value === NO_RESPONSE_CODE) return value;
|
|
5
3
|
if (!/^\d[\dX]{0,2}$/i.test(value)) return value;
|
|
6
4
|
return value.replace(/X+$/i, '');
|
|
7
5
|
};
|
|
@@ -2,15 +2,15 @@ import type { FieldValueOption } from '../../types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Build the `getSuggestions` callback for an HTTP status code field. The
|
|
4
4
|
* returned function:
|
|
5
|
-
* - on empty input, offers every
|
|
5
|
+
* - on empty input, offers every class mask (`0XX..5XX`)
|
|
6
6
|
* - on partial input (`"3"`, `"3X"`, `"30"`, …), expands it via
|
|
7
7
|
* `canonicalizeStatusCodeInput` and offers the single matching mask
|
|
8
8
|
* - merges any `context.selectedValues` (values already committed to the
|
|
9
9
|
* chip) in front of the input-driven output so they always appear with
|
|
10
10
|
* their canonical badge styling
|
|
11
11
|
*
|
|
12
|
-
* No backend config is required — the
|
|
13
|
-
* `
|
|
12
|
+
* No backend config is required — the class range is fixed to `[0..5]`
|
|
13
|
+
* (HTTP `1`–`5` plus Wallarm's `0` "no response" class).
|
|
14
14
|
*/
|
|
15
15
|
export declare const createStatusCodeSuggestions: () => ((inputText: string, context?: {
|
|
16
16
|
selectedValues?: Array<string | number | boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MASK_ROOTS,
|
|
1
|
+
import { MASK_ROOTS, canonicalizeStatusCodeInput, makeMask } from "./utils/index.js";
|
|
2
2
|
const createStatusCodeSuggestions = ()=>{
|
|
3
|
-
const resolveSelected = (selectedValues)=>(selectedValues ?? []).map((v)=>String(v)).filter((s)
|
|
3
|
+
const resolveSelected = (selectedValues)=>(selectedValues ?? []).map((v)=>String(v)).filter((s)=>/^\d[\dX]{0,2}$/.test(s) && MASK_ROOTS.includes(s.charAt(0))).map((s)=>makeMask(s));
|
|
4
4
|
return (inputText, context)=>{
|
|
5
5
|
const norm = inputText.trim();
|
|
6
6
|
const selected = resolveSelected(context?.selectedValues);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Build a validator for the HTTP status code field. Accepts only 3-character
|
|
3
|
-
* values whose leading digit is a valid
|
|
4
|
-
*
|
|
3
|
+
* values whose leading digit is a valid class root (`[0..5]` — `1`–`5` are the
|
|
4
|
+
* HTTP classes, `0` is Wallarm's "no response" class) and whose remaining two
|
|
5
|
+
* characters form one of:
|
|
5
6
|
* - `XX` (mask like `4XX`)
|
|
6
7
|
* - `dX` (narrowed mask like `40X`)
|
|
7
8
|
* - `dd` (concrete code like `401`)
|
|
8
9
|
*
|
|
9
|
-
* The `NO_RESPONSE_CODE` sentinel (`status_code=0`, published by the backend
|
|
10
|
-
* for attacks with no HTTP response) is also accepted even though it carries no
|
|
11
|
-
* HTTP class.
|
|
12
|
-
*
|
|
13
10
|
* Returns `true` when the value is invalid, matching the
|
|
14
11
|
* `FieldMetadata.validate` contract.
|
|
15
12
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MASK_ROOTS,
|
|
1
|
+
import { MASK_ROOTS, STATUS_CODE_LENGTH } from "./utils/index.js";
|
|
2
2
|
const createStatusCodeValidator = ()=>(value)=>{
|
|
3
3
|
const s = String(value);
|
|
4
|
-
if (s === NO_RESPONSE_CODE) return false;
|
|
5
4
|
if (s.length !== STATUS_CODE_LENGTH) return true;
|
|
6
5
|
if (!MASK_ROOTS.includes(s.charAt(0))) return true;
|
|
7
6
|
return !/^(XX|\dX|\d\d)$/.test(s.slice(1));
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Accepted inputs:
|
|
7
7
|
* "3" → "3XX" (single digit pads to full class mask)
|
|
8
|
+
* "0" → "0XX" (Wallarm's "no response" class)
|
|
8
9
|
* "3X" → "3XX" (partial mask)
|
|
9
10
|
* "3XX" → "3XX" (full mask)
|
|
10
11
|
* "30" → "30X" (two digits pad to narrowed mask)
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
* Rejected:
|
|
15
16
|
* "3X0" (digit after placeholder)
|
|
16
17
|
* "X30" (starts with placeholder)
|
|
17
|
-
* "6..." (leading digit outside the `[
|
|
18
|
+
* "6..." (leading digit outside the `[0..5]` class range)
|
|
18
19
|
* "ab..." (non-digit, non-X)
|
|
19
20
|
*/
|
|
20
21
|
export declare const canonicalizeStatusCodeInput: (input: string) => string | null;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
/** The
|
|
2
|
-
*
|
|
3
|
-
*
|
|
1
|
+
/** The valid status-code class roots, used both for suggestion-building and
|
|
2
|
+
* validation. `1`–`5` are the standard HTTP classes; `0` is Wallarm's
|
|
3
|
+
* "no HTTP response captured" class (the backend publishes `status_code=0`,
|
|
4
|
+
* shown as the `0XX` mask). Entirely frontend-driven, independent of what the
|
|
5
|
+
* backend config carries.
|
|
4
6
|
*
|
|
5
7
|
* Typed as `readonly string[]` (not `as const`) so `.includes(someString)`
|
|
6
8
|
* stays callable without casting; declaration-file generation rejects the
|
|
@@ -11,9 +13,3 @@ export declare const MASK_ROOTS: readonly string[];
|
|
|
11
13
|
export declare const STATUS_CODE_LENGTH = 3;
|
|
12
14
|
/** Placeholder character used inside masks (e.g. the `X` in `4XX`). */
|
|
13
15
|
export declare const MASK_PLACEHOLDER = "X";
|
|
14
|
-
/** The "no HTTP response captured" sentinel. The backend publishes
|
|
15
|
-
* `status_code=0` for attacks it never got a response for; it is a legitimate,
|
|
16
|
-
* filterable concrete value that sits outside the `1XX–5XX` HTTP classes, so
|
|
17
|
-
* the mask helpers treat it as a valid, neutrally-badged code rather than an
|
|
18
|
-
* incomplete class or an error. */
|
|
19
|
-
export declare const NO_RESPONSE_CODE = "0";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const MASK_ROOTS = [
|
|
2
|
+
'0',
|
|
2
3
|
'1',
|
|
3
4
|
'2',
|
|
4
5
|
'3',
|
|
@@ -7,5 +8,4 @@ const MASK_ROOTS = [
|
|
|
7
8
|
];
|
|
8
9
|
const STATUS_CODE_LENGTH = 3;
|
|
9
10
|
const MASK_PLACEHOLDER = 'X';
|
|
10
|
-
|
|
11
|
-
export { MASK_PLACEHOLDER, MASK_ROOTS, NO_RESPONSE_CODE, STATUS_CODE_LENGTH };
|
|
11
|
+
export { MASK_PLACEHOLDER, MASK_ROOTS, STATUS_CODE_LENGTH };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { canonicalizeStatusCodeInput } from './canonicalize';
|
|
2
|
-
export { MASK_PLACEHOLDER, MASK_ROOTS,
|
|
2
|
+
export { MASK_PLACEHOLDER, MASK_ROOTS, STATUS_CODE_LENGTH } from './constants';
|
|
3
3
|
export { makeMask } from './makeMask';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { canonicalizeStatusCodeInput } from "./canonicalize.js";
|
|
2
|
-
export { MASK_PLACEHOLDER, MASK_ROOTS,
|
|
2
|
+
export { MASK_PLACEHOLDER, MASK_ROOTS, STATUS_CODE_LENGTH } from "./constants.js";
|
|
3
3
|
export { makeMask } from "./makeMask.js";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { FieldValueOption } from '../../../types';
|
|
2
2
|
/** Build a `FieldValueOption` for a status-code mask or concrete code. Badge
|
|
3
3
|
* color is derived via the shared `ResponseCode` primitive so the two stay
|
|
4
|
-
* in sync.
|
|
5
|
-
*
|
|
4
|
+
* in sync.
|
|
5
|
+
*
|
|
6
|
+
* The `0XX` class (Wallarm's "no HTTP response captured", backend
|
|
7
|
+
* `status_code=0`) has no standard HTTP category, so it renders as a neutral
|
|
8
|
+
* slate pill. Any other value outside the `1XX–5XX` classes throws — this is
|
|
9
|
+
* unreachable in practice because callers gate on `MASK_ROOTS`, but the check
|
|
6
10
|
* is kept as a safety net so a future refactor can't silently emit a
|
|
7
|
-
* colorless pill.
|
|
8
|
-
* sentinel, which is a legitimate value with no HTTP class and renders as a
|
|
9
|
-
* neutral slate pill. */
|
|
11
|
+
* colorless pill. */
|
|
10
12
|
export declare const makeMask: (label: string) => FieldValueOption;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { RESPONSE_CODE_COLOR, getResponseCodeCategory } from "../../../../ResponseCode/index.js";
|
|
2
|
-
import { NO_RESPONSE_CODE } from "./constants.js";
|
|
3
2
|
const makeMask = (label)=>{
|
|
4
3
|
const category = getResponseCodeCategory(label);
|
|
5
4
|
if ('unknown' === category) {
|
|
6
|
-
if (label
|
|
5
|
+
if (label.startsWith('0')) return {
|
|
7
6
|
value: label,
|
|
8
7
|
label,
|
|
9
8
|
badge: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wallarm-org/design-system",
|
|
3
|
-
"version": "0.88.1-rc-fix-status-code-zero-value.
|
|
3
|
+
"version": "0.88.1-rc-fix-status-code-zero-value.2",
|
|
4
4
|
"description": "Core design system library with React components and Storybook documentation",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|