Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INT-1297: Preserve whitespace for byte array results #22

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run-int-dev-checklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
run-integration-development-checklist:
runs-on: ubuntu-latest
container: 'centos:7'
container: 'rockylinux:8'

steps:
- uses: actions/checkout@v2
Expand Down
940 changes: 476 additions & 464 deletions config/config.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"onDemandOnly": true,
"defaultColor": "light-green",
"logging": { "level": "info" },
"entityTypes": ["*"],
"entityTypes": ["IPv4", "IPv6", "IPv4CIDR", "MD5", "SHA1", "SHA256", "MD5", "email", "domain", "cve", "string"],
"customTypes": [{ "key": "encodedString", "regex": "\\S[\\s\\S]{2,9999}\\S" }],
"styles": ["./styles/style.less"],
"block": {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CyberChefIntegration",
"version": "3.2.9",
"version": "3.2.10",
"main": "./integration.js",
"private": true,
"dependencies": {
Expand Down
19 changes: 17 additions & 2 deletions src/getDisplayResults.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
const fp = require('lodash/fp');

const CHARCODE_SPACE = 32;
const CHARCODE_TAB = 9;
const CHARCODE_LINE_FEED = 10;
const CHARCODE_LINE_TABULATION = 11;
const CHARCODE_FORM_FEED = 12;
const CHARCODE_CARRIAGE_RETURN = 13;

const PRINTABLE_WHITESPACE_CHARACTERS = [
CHARCODE_SPACE,
CHARCODE_TAB,
CHARCODE_LINE_FEED,
CHARCODE_LINE_TABULATION,
CHARCODE_FORM_FEED,
CHARCODE_CARRIAGE_RETURN
];

const getByteArrayDisplayResults = (resultValue) => {
const stringifiedByteArray = String.fromCharCode.apply(
null,
resultValue.filter((x) => x > 32)
resultValue.filter((x) => x > 31 || PRINTABLE_WHITESPACE_CHARACTERS.includes(x))
);

return {
displayResult: stringifiedByteArray,
outputLength: fp.flow(fp.toString, fp.size)(stringifiedByteArray),
Expand Down
3 changes: 2 additions & 1 deletion styles/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ pre {

&.output {
line-height: 15px;
font-size: 11px;
font-size: 12px;

.output-title {
margin-bottom: 4px;
Expand Down Expand Up @@ -1135,6 +1135,7 @@ pre {
.show-whitespace {
white-space: pre-wrap;
word-wrap: break-word;
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.error-message {
Expand Down
Loading