Skip to content

Commit

Permalink
slight ui tweak for handling newlines in array entries in modals
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Feb 13, 2025
1 parent f363544 commit 9741c7a
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 17 deletions.
6 changes: 6 additions & 0 deletions MythicReactUI/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.10] - 2025-02-13

### Changed

- Updated processing of arrays and typedarrays to have option to not split on newlines

## [0.3.9] - 2025-02-07

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const CallbacksTabsTaskingPanel = ({tabInfo, index, value, onCloseTab, pa
const [commandInfo, setCommandInfo] = React.useState({});
const [taskingData, setTaskingData] = React.useState({task: []});
const taskingDataRef = React.useRef({task: []});
const [fromNow, setFromNow] = React.useState(getSkewedNow());
const [fromNow, setFromNow] = React.useState(getSkewedNow().toISOString());
const [selectedToken, setSelectedToken] = React.useState({});
const [filterOptions, setFilterOptions] = React.useState({
"operatorsList": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ export function TaskParametersDialogRow(props){
snackActions.error("Failed to create credential");
console.log(data);
}
})
});
const [treatNewlinesAsNewEntries, setTreatNewlinesAsNewEntries] = React.useState(false);
useEffect( () => {
if(props.dynamic_query_function !== ""){
if(!usingDynamicParamChoices.current){
Expand Down Expand Up @@ -503,12 +504,19 @@ export function TaskParametersDialogRow(props){
setArrayValue(removed);
props.onChange(props.name, removed, false);
}
const toggleTreatNewlinesAsNewEntries = () => {
setTreatNewlinesAsNewEntries(!treatNewlinesAsNewEntries);
}
const onChangeArrayText = (value, error, index) => {
let values = [...arrayValue];
if(value.includes("\n")){
let new_values = value.split("\n");
values = [...values, ...new_values.slice(1)];
values[index] = new_values[0];
if(treatNewlinesAsNewEntries){
let new_values = value.split("\n");
values = [...values, ...new_values.slice(1)];
values[index] = new_values[0];
} else {
values[index] = value;
}
}else{
values[index] = value;
}
Expand Down Expand Up @@ -537,9 +545,13 @@ export function TaskParametersDialogRow(props){
const onChangeTypedArrayText = (value, error, index) => {
let values = [...typedArrayValue];
if(value.includes("\n")){
let new_values = value.split("\n");
values = [...values, [props.default_value, ...new_values.slice(1)]];
values[index][1] = new_values[0];
if(treatNewlinesAsNewEntries){
let new_values = value.split("\n");
values = [...values, [props.default_value, ...new_values.slice(1)]];
values[index][1] = new_values[0];
} else {
values[index][1] = value;
}
}else{
values[index][1] = value;
}
Expand Down Expand Up @@ -623,6 +635,16 @@ export function TaskParametersDialogRow(props){
case "Array":
return (
<TableContainer >
<Table size="small" style={{tableLayout: "fixed", maxWidth: "100%", "overflow": "auto"}}>
<TableBody>
<TableRow>
<MythicStyledTableCell>Treat new lines as new entries</MythicStyledTableCell>
<MythicStyledTableCell>
<Switch checked={treatNewlinesAsNewEntries} onChange={toggleTreatNewlinesAsNewEntries} color={"info"} />
</MythicStyledTableCell>
</TableRow>
</TableBody>
</Table>
<Table size="small" style={{tableLayout: "fixed", maxWidth: "100%", "overflow": "auto"}}>
<TableBody>
{arrayValue.map( (a, i) => (
Expand Down Expand Up @@ -658,6 +680,16 @@ export function TaskParametersDialogRow(props){
case "TypedArray":
return (
<TableContainer >
<Table size="small" style={{tableLayout: "fixed", maxWidth: "100%", "overflow": "auto"}}>
<TableBody>
<TableRow>
<MythicStyledTableCell>Treat new lines as new entries</MythicStyledTableCell>
<MythicStyledTableCell>
<Switch checked={treatNewlinesAsNewEntries} onChange={toggleTreatNewlinesAsNewEntries} color={"info"} />
</MythicStyledTableCell>
</TableRow>
</TableBody>
</Table>
<Table size="small" style={{tableLayout: "fixed", maxWidth: "100%", "overflow": "auto"}}>
<TableBody>
{typedArrayValue.map( (a, i) => (
Expand Down
2 changes: 1 addition & 1 deletion MythicReactUI/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import jwt_decode from 'jwt-decode';
import {meState} from './cache';
import {getSkewedNow} from "./components/utilities/Time";

export const mythicUIVersion = "0.3.9";
export const mythicUIVersion = "0.3.10";

let fetchingNewToken = false;

Expand Down
6 changes: 3 additions & 3 deletions mythic-react-docker/mythic/public/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"files": {
"main.css": "/new/static/css/main.602591e6.css",
"main.js": "/new/static/js/main.a8ffde72.js",
"main.js": "/new/static/js/main.a6a04f67.js",
"static/media/mythic-red.png": "/new/static/media/mythic-red.203468a4e5240d239aa0.png",
"static/media/graphql.png": "/new/static/media/graphql.8f15978b39b0870a9f0e.png",
"static/media/Mythic_Logo.svg": "/new/static/media/Mythic_Logo.6842c911bebe36d6f83fc7ced4a2cd99.svg",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.602591e6.css.map": "/new/static/css/main.602591e6.css.map",
"main.a8ffde72.js.map": "/new/static/js/main.a8ffde72.js.map"
"main.a6a04f67.js.map": "/new/static/js/main.a6a04f67.js.map"
},
"entrypoints": [
"static/css/main.602591e6.css",
"static/js/main.a8ffde72.js"
"static/js/main.a6a04f67.js"
]
}
2 changes: 1 addition & 1 deletion mythic-react-docker/mythic/public/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.a8ffde72.js"></script><link href="/new/static/css/main.602591e6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.a6a04f67.js"></script><link href="/new/static/css/main.602591e6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 9741c7a

Please sign in to comment.