Skip to content

Commit 7ed7fca

Browse files
authored
Merge branch 'master' into feat/1216-1531-upgrade-uuid
2 parents a0ade26 + 5d33531 commit 7ed7fca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3011
-107
lines changed

.github/workflows/releases.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525

2626
- name: Install
2727
run: |
28+
export DETECT_CHROMEDRIVER_VERSION=true
2829
npm ci
2930
npm run setheapsize
3031
@@ -61,12 +62,22 @@ jobs:
6162
tags: ${{ steps.image-metadata.outputs.tags }}
6263
labels: ${{ steps.image-metadata.outputs.labels }}
6364
containerfiles: ./Dockerfile
64-
platforms: linux/amd64
65+
platforms: linux/amd64,linux/arm64
6566
oci: true
67+
# enable build layer caching between platforms
68+
layers: true
6669
# Webpack seems to use a lot of open files, increase the max open file limit to accomodate.
6770
extra-args: |
6871
--ulimit nofile=10000
6972
73+
- name: Publish to GHCR
74+
uses: redhat-actions/push-to-registry@v2
75+
with:
76+
image: ${{ steps.build-image.outputs.image }}
77+
tags: ${{ steps.build-image.outputs.tags }}
78+
registry: ${{ env.REGISTRY }}
79+
username: ${{ env.REGISTRY_USER }}
80+
password: ${{ env.REGISTRY_PASSWORD }}
7081

7182
- name: Upload Release Assets
7283
id: upload-release-assets
@@ -83,11 +94,3 @@ jobs:
8394
uses: JS-DevTools/npm-publish@v1
8495
with:
8596
token: ${{ secrets.NPM_TOKEN }}
86-
87-
- name: Publish to GHCR
88-
uses: redhat-actions/push-to-registry@v2
89-
with:
90-
tags: ${{ steps.build-image.outputs.tags }}
91-
registry: ${{ env.REGISTRY }}
92-
username: ${{ env.REGISTRY_USER }}
93-
password: ${{ env.REGISTRY_PASSWORD }}

Dockerfile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,35 @@
1-
FROM node:18-alpine AS build
1+
#####################################
2+
# Build the app to a static website #
3+
#####################################
4+
# Modifier --platform=$BUILDPLATFORM limits the platform to "BUILDPLATFORM" during buildx multi-platform builds
5+
# This is because npm "chromedriver" package is not compatiable with all platforms
6+
# For more info see: https://docs.docker.com/build/building/multi-platform/#cross-compilation
7+
FROM --platform=$BUILDPLATFORM node:18-alpine AS builder
28

9+
WORKDIR /app
10+
11+
COPY package.json .
12+
COPY package-lock.json .
13+
14+
# Install dependencies
15+
# --ignore-scripts prevents postinstall script (which runs grunt) as it depends on files other than package.json
16+
RUN npm ci --ignore-scripts
17+
18+
# Copy files needed for postinstall and build
319
COPY . .
4-
RUN npm ci
20+
21+
# npm postinstall runs grunt, which depends on files other than package.json
22+
RUN npm run postinstall
23+
24+
# Build the app
525
RUN npm run build
626

7-
FROM nginx:1.25-alpine3.18 AS cyberchef
27+
#########################################
28+
# Package static build files into nginx #
29+
#########################################
30+
# We are using Github Actions: redhat-actions/buildah-build@v2 which needs manual selection of arch in base image
31+
# Remove TARGETARCH if docker buildx is supported in the CI release as --platform=$TARGETPLATFORM will be automatically set
32+
ARG TARGETPLATFORM
33+
FROM --platform=${TARGETPLATFORM} nginx:stable-alpine AS cyberchef
834

9-
COPY --from=build ./build/prod /usr/share/nginx/html/
35+
COPY --from=builder /app/build/prod /usr/share/nginx/html/

package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"d3": "7.9.0",
124124
"d3-hexbin": "^0.2.2",
125125
"diff": "^5.2.0",
126+
"dompurify": "^3.2.5",
126127
"es6-promisify": "^7.0.0",
127128
"escodegen": "^2.1.0",
128129
"esprima": "^4.0.1",
@@ -131,6 +132,7 @@
131132
"file-saver": "^2.0.5",
132133
"flat": "^6.0.1",
133134
"geodesy": "1.1.3",
135+
"hash-wasm": "^4.12.0",
134136
"highlight.js": "^11.9.0",
135137
"ieee754": "^1.2.1",
136138
"jimp": "^0.22.12",
@@ -139,6 +141,7 @@
139141
"js-sha3": "^0.9.3",
140142
"jsesc": "^3.0.2",
141143
"json5": "^2.2.3",
144+
"jsonata": "^2.0.3",
142145
"jsonpath-plus": "^9.0.0",
143146
"jsonwebtoken": "8.5.1",
144147
"jsqr": "^1.4.0",

src/core/config/Categories.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@
294294
"To Upper case",
295295
"To Lower case",
296296
"Swap case",
297+
"Alternating Caps",
297298
"To Case Insensitive Regex",
298299
"From Case Insensitive Regex",
299300
"Add line numbers",
@@ -369,6 +370,7 @@
369370
"Regular expression",
370371
"XPath expression",
371372
"JPath expression",
373+
"Jsonata Query",
372374
"CSS selector",
373375
"Extract EXIF",
374376
"Extract ID3",
@@ -404,6 +406,7 @@
404406
"name": "Hashing",
405407
"ops": [
406408
"Analyse hash",
409+
"Generate all checksums",
407410
"Generate all hashes",
408411
"MD2",
409412
"MD4",
@@ -422,6 +425,7 @@
422425
"Snefru",
423426
"BLAKE2b",
424427
"BLAKE2s",
428+
"BLAKE3",
425429
"GOST Hash",
426430
"Streebog",
427431
"SSDEEP",
@@ -446,7 +450,8 @@
446450
"Adler-32 Checksum",
447451
"Luhn Checksum",
448452
"CRC Checksum",
449-
"TCP/IP Checksum"
453+
"TCP/IP Checksum",
454+
"XOR Checksum"
450455
]
451456
},
452457
{
@@ -470,6 +475,7 @@
470475
"Jq",
471476
"CSS selector",
472477
"PHP Deserialize",
478+
"PHP Serialize",
473479
"Microsoft Script Decoder",
474480
"Strip HTML tags",
475481
"Diff",

src/core/lib/Base32.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// import Utils from "../Utils.mjs";
2+
3+
/**
4+
* Base32 resources.
5+
*
6+
* @author Peter C-S [[email protected]]
7+
* @license Apache-2.0
8+
*/
9+
10+
/**
11+
* Base32 alphabets.
12+
*/
13+
export const ALPHABET_OPTIONS = [
14+
{
15+
name: "Standard", // https://www.rfc-editor.org/rfc/rfc4648#section-6
16+
value: "A-Z2-7=",
17+
},
18+
{
19+
name: "Hex Extended", // https://www.rfc-editor.org/rfc/rfc4648#section-7
20+
value: "0-9A-V=",
21+
},
22+
];
23+

src/core/operations/AESDecrypt.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class AESDecrypt extends Operation {
112112
run(input, args) {
113113
const key = Utils.convertToByteString(args[0].string, args[0].option),
114114
iv = Utils.convertToByteString(args[1].string, args[1].option),
115-
mode = args[2].substring(0, 3),
115+
mode = args[2].split("/")[0],
116116
noPadding = args[2].endsWith("NoPadding"),
117117
inputType = args[3],
118118
outputType = args[4],

src/core/operations/AESEncrypt.mjs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ class AESEncrypt extends Operation {
6666
{
6767
name: "ECB",
6868
off: [5]
69+
},
70+
{
71+
name: "CBC/NoPadding",
72+
off: [5]
73+
},
74+
{
75+
name: "ECB/NoPadding",
76+
off: [5]
6977
}
7078
]
7179
},
@@ -98,7 +106,8 @@ class AESEncrypt extends Operation {
98106
run(input, args) {
99107
const key = Utils.convertToByteString(args[0].string, args[0].option),
100108
iv = Utils.convertToByteString(args[1].string, args[1].option),
101-
mode = args[2],
109+
mode = args[2].split("/")[0],
110+
noPadding = args[2].endsWith("NoPadding"),
102111
inputType = args[3],
103112
outputType = args[4],
104113
aad = Utils.convertToByteString(args[5].string, args[5].option);
@@ -114,11 +123,20 @@ The following algorithms will be used based on the size of the key:
114123

115124
input = Utils.convertToByteString(input, inputType);
116125

126+
// Handle NoPadding modes
127+
if (noPadding && input.length % 16 !== 0) {
128+
throw new OperationError("Input length must be a multiple of 16 bytes for NoPadding modes.");
129+
}
117130
const cipher = forge.cipher.createCipher("AES-" + mode, key);
118131
cipher.start({
119132
iv: iv,
120133
additionalData: mode === "GCM" ? aad : undefined
121134
});
135+
if (noPadding) {
136+
cipher.mode.pad = function(output, options) {
137+
return true;
138+
};
139+
}
122140
cipher.update(forge.util.createBuffer(input));
123141
cipher.finish();
124142

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @author sw5678
3+
* @copyright Crown Copyright 2023
4+
* @license Apache-2.0
5+
*/
6+
7+
import Operation from "../Operation.mjs";
8+
9+
/**
10+
* Alternating caps operation
11+
*/
12+
class AlternatingCaps extends Operation {
13+
14+
/**
15+
* AlternatingCaps constructor
16+
*/
17+
constructor() {
18+
super();
19+
20+
this.name = "Alternating Caps";
21+
this.module = "Default";
22+
this.description = "Alternating caps, also known as studly caps, sticky caps, or spongecase is a form of text notation in which the capitalization of letters varies by some pattern, or arbitrarily. An example of this would be spelling 'alternative caps' as 'aLtErNaTiNg CaPs'.";
23+
this.infoURL = "https://en.wikipedia.org/wiki/Alternating_caps";
24+
this.inputType = "string";
25+
this.outputType = "string";
26+
this.args= [];
27+
}
28+
29+
/**
30+
* @param {string} input
31+
* @param {Object[]} args
32+
* @returns {string}
33+
*/
34+
run(input, args) {
35+
let output = "";
36+
let previousCaps = true;
37+
for (let i = 0; i < input.length; i++) {
38+
// Check if the element is a letter
39+
if (!RegExp(/^\p{L}/, "u").test(input[i])) {
40+
output += input[i];
41+
} else if (previousCaps) {
42+
output += input[i].toLowerCase();
43+
previousCaps = false;
44+
} else {
45+
output += input[i].toUpperCase();
46+
previousCaps = true;
47+
}
48+
}
49+
return output;
50+
}
51+
}
52+
53+
export default AlternatingCaps;

0 commit comments

Comments
 (0)