@truedat/dq 5.12.2 → 5.12.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truedat/dq",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.4",
|
|
4
4
|
"description": "Truedat Web Data Quality Module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"jsnext:main": "src/index.js",
|
|
@@ -118,5 +118,5 @@
|
|
|
118
118
|
"react-dom": ">= 16.8.6 < 17",
|
|
119
119
|
"semantic-ui-react": ">= 2.0.3 < 2.2"
|
|
120
120
|
},
|
|
121
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "3a781fb5722e184e3bef25f9dcc7644bd463987b"
|
|
122
122
|
}
|
|
@@ -142,7 +142,7 @@ export const RuleImplementationRawForm = ({
|
|
|
142
142
|
|
|
143
143
|
const getBannedWordsAndChars = (text) => {
|
|
144
144
|
const re =
|
|
145
|
-
/\b(DROP|DELETE|INSERT|UPDATE|CALL|EXEC|EXECUTE|ALTER)\b
|
|
145
|
+
/\b(DROP|DELETE|DEL|INSERT|UPDATE|CALL|EXEC|EXECUTE|ALTER|CREATE)\b|--/gi;
|
|
146
146
|
return text ? text.match(re) : [];
|
|
147
147
|
};
|
|
148
148
|
const validInformation = () =>
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { encodeRawContent } from "../encodeRawContent";
|
|
2
|
+
const { TextEncoder } = require("util");
|
|
3
|
+
|
|
4
|
+
// https://stackoverflow.com/a/68468204
|
|
5
|
+
Object.assign(global, { TextEncoder });
|
|
2
6
|
|
|
3
7
|
describe("services: encodeRawContent", () => {
|
|
4
8
|
it("should base64 encode raw_content dataset, population and validations", () => {
|
|
5
9
|
const raw_content = {
|
|
6
10
|
dataset: "FROM SOME_TABLE",
|
|
7
|
-
population: "TYPE = '
|
|
11
|
+
population: "TYPE = '人間'",
|
|
8
12
|
validations: "PERSON_ID IS NOT NULL",
|
|
9
|
-
foo: "bar"
|
|
13
|
+
foo: "bar",
|
|
10
14
|
};
|
|
11
15
|
const ruleImplementation = { foo: "bar", raw_content };
|
|
12
16
|
expect(encodeRawContent(ruleImplementation)).toMatchObject({
|
|
@@ -14,9 +18,9 @@ describe("services: encodeRawContent", () => {
|
|
|
14
18
|
raw_content: {
|
|
15
19
|
foo: "bar",
|
|
16
20
|
dataset: "RlJPTSBTT01FX1RBQkxF",
|
|
17
|
-
population: "
|
|
18
|
-
validations: "UEVSU09OX0lEIElTIE5PVCBOVUxM"
|
|
19
|
-
}
|
|
21
|
+
population: "VFlQRSA9ICfkurrplpMn",
|
|
22
|
+
validations: "UEVSU09OX0lEIElTIE5PVCBOVUxM",
|
|
23
|
+
},
|
|
20
24
|
});
|
|
21
25
|
});
|
|
22
26
|
|
|
@@ -24,7 +28,7 @@ describe("services: encodeRawContent", () => {
|
|
|
24
28
|
const raw_content = {
|
|
25
29
|
dataset: null,
|
|
26
30
|
population: "",
|
|
27
|
-
validations: ""
|
|
31
|
+
validations: "",
|
|
28
32
|
};
|
|
29
33
|
const ruleImplementation = { foo: "bar", raw_content };
|
|
30
34
|
expect(encodeRawContent(ruleImplementation)).toStrictEqual(
|
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import _ from "lodash/fp";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const stringToBase64 = (value) =>
|
|
4
|
+
_.isNil(value)
|
|
5
|
+
? value
|
|
6
|
+
: _.flow((value) => new TextEncoder().encode(value), bytesToBase64)(value);
|
|
7
|
+
|
|
8
|
+
// https://developer.mozilla.org/en-US/docs/Glossary/Base64#the_unicode_problem
|
|
9
|
+
const bytesToBase64 = (bytes) => {
|
|
10
|
+
const binString = Array.from(bytes, (x) => String.fromCodePoint(x)).join("");
|
|
11
|
+
return btoa(binString);
|
|
12
|
+
};
|
|
4
13
|
|
|
5
14
|
const encodeProps = (o) =>
|
|
6
15
|
_.flow(
|
|
7
16
|
_.pick(["dataset", "population", "validations", "segments"]),
|
|
8
|
-
_.mapValues(
|
|
17
|
+
_.mapValues(stringToBase64),
|
|
9
18
|
_.assign(o)
|
|
10
19
|
)(o);
|
|
11
20
|
|
|
@@ -13,6 +22,9 @@ export const encodeRawContent = (ruleImplementation) =>
|
|
|
13
22
|
_.has("raw_content.dataset")(ruleImplementation)
|
|
14
23
|
? {
|
|
15
24
|
...ruleImplementation,
|
|
25
|
+
/* OWASP-enabled firewalls identify these requests as potential SQL
|
|
26
|
+
* injection attacks, avoid detection by base 64 encoding
|
|
27
|
+
*/
|
|
16
28
|
raw_content: encodeProps(ruleImplementation.raw_content),
|
|
17
29
|
}
|
|
18
30
|
: ruleImplementation;
|