ac-sanitizer 4.0.1 → 4.0.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.
@@ -0,0 +1,30 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ master ]
9
+ pull_request:
10
+ branches: [ master ]
11
+
12
+ jobs:
13
+ build:
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [16.x, 18.x]
20
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21
+
22
+ steps:
23
+ - uses: actions/checkout@v3
24
+ - name: Use Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v3
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+
29
+ - run: yarn install
30
+ - run: yarn run test
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ <a name="4.0.2"></a>
2
+
3
+ ## [4.0.2](https://github.com/mmpro/ac-sanitizer/compare/v4.0.1..v4.0.2) (2023-06-18 11:35:24)
4
+
5
+
6
+ ### Bug Fix
7
+
8
+ * **App:** If base64 is an object, parse the converted string | MP | [cf9a49d9df121c7829932ae37192fd22f3d98438](https://github.com/mmpro/ac-sanitizer/commit/cf9a49d9df121c7829932ae37192fd22f3d98438)
9
+ Base64 might be a string or a stringified object. Try parsing the string to determine if it is an object
10
+ Related issues: [undefined/undefined#master](undefined/browse/master)
11
+ ### Chores
12
+
13
+ * **App:** Updated packages | MP | [49da6b224e9382aa7cc6a298b2a0af06648931b8](https://github.com/mmpro/ac-sanitizer/commit/49da6b224e9382aa7cc6a298b2a0af06648931b8)
14
+ Updated packages
15
+ Related issues: [undefined/undefined#master](undefined/browse/master)
16
+ ### Chores
17
+
18
+ * **App:** Add Github workflow | MP | [72668a139dda85330516077ef471af4aa4b68c3b](https://github.com/mmpro/ac-sanitizer/commit/72668a139dda85330516077ef471af4aa4b68c3b)
19
+ Add Github workflow
20
+ Related issues: [undefined/undefined#master](undefined/browse/master)
1
21
  <a name="4.0.1"></a>
2
22
 
3
23
  ## [4.0.1](https://github.com/mmpro/ac-sanitizer/compare/v4.0.0..v4.0.1) (2023-04-18 18:38:15)
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # AC Sanitizer
2
2
  Sanitizes payloads with given field definitions
3
3
 
4
+ [![Node.js CI](https://github.com/AdmiralCloud/ac-sanitizer/actions/workflows/node.js.yml/badge.svg)](https://github.com/AdmiralCloud/ac-sanitizer/actions/workflows/node.js.yml)
5
+
4
6
  ### Version 4 - Breaking changes
5
7
  Version 4 requires Node 16.
6
8
 
package/index.js CHANGED
@@ -330,6 +330,13 @@ const sanitizer = function() {
330
330
  if (!validator.isBase64(_.padEnd(value, (l+pad), '='))) error = { message: fieldName + '_notABase64String' }
331
331
  else if (field.convert) {
332
332
  _.set(paramsToCheck, fieldName, Buffer.from(value, 'base64').toString())
333
+ // the value might be a stringified object - try converting it
334
+ try {
335
+ _.set(paramsToCheck, fieldName, JSON.parse(_.get(paramsToCheck, fieldName)))
336
+ }
337
+ catch(e) {
338
+ // ignore
339
+ }
333
340
  }
334
341
  }
335
342
  }
package/package.json CHANGED
@@ -4,21 +4,21 @@
4
4
  "author": "Mark Poepping (https://www.admiralcloud.com)",
5
5
  "license": "MIT",
6
6
  "repository": "admiralcloud/ac-sanitizer",
7
- "version": "4.0.1",
7
+ "version": "4.0.2",
8
8
  "homepage": "https://www.admiralcloud.com",
9
9
  "dependencies": {
10
10
  "ac-countrylist": "^1.0.7",
11
11
  "ac-file-extensions": "^2.0.5",
12
12
  "ac-ip": "^3.0.1",
13
13
  "chai": "^4.3.7",
14
- "date-and-time": "^2.4.3",
15
- "hashids": "^2.2.11",
14
+ "date-and-time": "^3.0.2",
15
+ "hashids": "^2.3.0",
16
16
  "lodash": "^4.17.21",
17
17
  "validator": "^13.9.0"
18
18
  },
19
19
  "devDependencies": {
20
- "ac-semantic-release": "^0.4.0",
21
- "eslint": "^8.38.0",
20
+ "ac-semantic-release": "^0.4.1",
21
+ "eslint": "^8.43.0",
22
22
  "mocha": "^10.2.0",
23
23
  "nyc": "^15.1.0"
24
24
  },
@@ -13,6 +13,8 @@ module.exports = {
13
13
  { name: 'Invalid base64 with convert', type: 'base64', convert: true, value: 123, error: 'base64_mustBeString' },
14
14
  { name: 'Base64 app.admiralcloud.com - requires padding', type: 'base64', value: 'aHR0cHM6Ly9hcHAuYWRtaXJhbGNsb3VkLmNvbQ', convert: true, expected: 'https://app.admiralcloud.com' },
15
15
  { name: 'Base64 app.admiralcloud.com - with padding', type: 'base64', value: 'aHR0cHM6Ly9hcHAuYWRtaXJhbGNsb3VkLmNvbQ==', convert: true, expected: 'https://app.admiralcloud.com' },
16
+ { name: 'Base64 encoded object', type: 'base64', value: 'eyJ1c2VySWQiOjEyMywiY3VzdG9tZXJJZCI6MTQ2LCJyZWFzb24iOiJCZWNhdXNlIEkgY2FuIn0=', convert: true, expected: { userId: 123, customerId: 146, reason: 'Because I can' } },
17
+ { name: 'Base64 encoded object', type: 'base64', value: 'eyJ1c2VySWQiOjEyMywiY3VzdG9tZXJJZCI6MTQ2LCJyZWFzbOiJCZWNhdXNlIEkgY2FuIn0=', convert: true, error: 'base64_notABase64String' },
16
18
  ]
17
19
 
18
20
  _.forEach(baseTests, (test) => {
@@ -34,7 +36,7 @@ module.exports = {
34
36
  }
35
37
  }
36
38
  else {
37
- expect(_.get(r, 'params.base64')).to.equal(_.get(test, 'expected'))
39
+ expect(_.get(r, 'params.base64')).to.eql(_.get(test, 'expected'))
38
40
  }
39
41
  return done()
40
42
  })