Skip to content

Commit

Permalink
More UI array fixes
Browse files Browse the repository at this point in the history
also auto select c2 profile when selecting saved c2 instance
  • Loading branch information
its-a-feature committed Mar 30, 2024
1 parent 282cd32 commit 7535e55
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
7 changes: 7 additions & 0 deletions MythicReactUI/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ 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.1.86] - 2024-03-30

### Changed

- Fixed an issue with array values not getting parsed properly when getting set from saved instances in payload creation
- If you select a pre-created profile instance when generating a payload, then the associated c2 profile is toggled on automatically

## [0.1.85] - 2024-03-30

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ export function Step4C2Profiles(props){
const canceled = () => {
props.canceled();
}
const toggleC2Selection = (evt, c2) => {
const toggleC2Selection = (evt, c2, selected) => {
const updatedc2 = c2Profiles.map( (curc2) => {
if(c2.name === curc2.name){
return {...curc2, selected: !curc2.selected}
return {...curc2, selected: selected}
}
return curc2;
});
Expand All @@ -195,9 +195,17 @@ export function Step4C2Profiles(props){
const updates = data.c2profileparametersinstance.map( (cur) => {
let inst = {...cur, ...cur.c2profileparameter};
if(inst.parameter_type === "Array" || inst.parameter_type === "ChooseMultiple" || inst.parameter_type === "TypedArray"){
inst["value"] = inst["value"];
try{
inst["value"] = JSON.parse(inst["value"]);
}catch(error){
inst["value"] = inst["value"];
}
try{
inst["trackedValue"] = JSON.parse(inst["value"]);
}catch(error){
inst["trackedValue"] = inst["value"];
}
inst["initialValue"] = getDefaultValueForType(inst);
inst["trackedValue"] = JSON.parse(inst["value"]);
inst["choices"] = getDefaultChoices(inst);
} else if(inst.parameter_type === "Dictionary"){
//
Expand Down Expand Up @@ -277,6 +285,7 @@ export function Step4C2Profiles(props){
//setSelectedInstance(evt.target.value);
const updatedc2 = c2Profiles.map( (curc2) => {
if(c2.name === curc2.name){
curc2.selected = true;
curc2.c2profileparameters = [];
}
return curc2;
Expand Down Expand Up @@ -319,7 +328,7 @@ export function Step4C2Profiles(props){

<Switch
checked={c2.selected}
onChange={evt => toggleC2Selection(evt, c2)}
onChange={evt => toggleC2Selection(evt, c2, !c2.selected)}
inputProps={{ 'aria-label': 'primary checkbox' }}
name="active"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,20 @@ export function C2ProfileSavedInstancesDialog(props) {
});
const [getInstanceValues] = useLazyQuery(getProfileInstanceQuery, {
onCompleted: (data) => {
console.log(data);
try{
const updates = data.c2profileparametersinstance.map( (cur) => {
let inst = {...cur, ...cur.c2profileparameter};
if(inst.parameter_type === "Array" || inst.parameter_type === "ChooseMultiple"){
console.log(inst);
inst["value"] = inst["value"];
inst["trackedValue"] = JSON.parse(inst["value"]);
try{
inst["value"] = JSON.parse(inst["value"]);
}catch(error){
inst["value"] = inst["value"];
}
try{
inst["trackedValue"] = JSON.parse(inst["value"]);
}catch(error){
inst["trackedValue"] = inst["value"];
}
inst["choices"] = getDefaultChoices(inst);
inst["initialValue"] = getDefaultValueForType(inst);
} else if(inst.parameter_type === "Dictionary") {
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';

export const mythicVersion = "3.2.20-rc7";
export const mythicUIVersion = "0.1.85";
export const mythicUIVersion = "0.1.86";

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,15 +1,15 @@
{
"files": {
"main.css": "/new/static/css/main.00d51b79.css",
"main.js": "/new/static/js/main.943d8e71.js",
"main.js": "/new/static/js/main.ba207a79.js",
"static/media/mythic@2x.png": "/new/static/media/mythic@2x.7c5b62b471ac779fd706.png",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.00d51b79.css.map": "/new/static/css/main.00d51b79.css.map",
"main.943d8e71.js.map": "/new/static/js/main.943d8e71.js.map"
"main.ba207a79.js.map": "/new/static/js/main.ba207a79.js.map"
},
"entrypoints": [
"static/css/main.00d51b79.css",
"static/js/main.943d8e71.js"
"static/js/main.ba207a79.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.943d8e71.js"></script><link href="/new/static/css/main.00d51b79.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.ba207a79.js"></script><link href="/new/static/css/main.00d51b79.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 7535e55

Please sign in to comment.