Skip to content

Commit

Permalink
UI v0.1.58
Browse files Browse the repository at this point in the history
fixing an issue with mismatched parameter names in modal populations
  • Loading branch information
its-a-feature committed Jan 22, 2024
1 parent 6e4d6a7 commit fdcfe27
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 23 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.1.58] - 2024-01-22

### Changed

- Fixed an issue with mismatched command parameter name, cli_name, and display_name not auto populating with modals

## [0.1.57] - 2024-01-17

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,19 @@ query getCredentialsQuery($operation_id: Int!){
}
}
`;

export const commandInParsedParameters = (cmd, parsedParameters) =>{
if(cmd.name in parsedParameters){
return cmd.name
}
if(cmd.cli_name in parsedParameters){
return cmd.cli_name
}
if(cmd.display_name in parsedParameters){
return cmd.display_name
}
return undefined
}
export function TaskParametersDialog(props) {
const theme = useTheme();
const [backdropOpen, setBackdropOpen] = React.useState(false);
Expand Down Expand Up @@ -435,40 +448,41 @@ export function TaskParametersDialog(props) {
return [...prev];
}
//console.log(props.command);

let parsedParameterName = commandInParsedParameters(cmd, props.command.parsedParameters);
switch(cmd.type){
case "Boolean":
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, value: props.command.parsedParameters[cmd.name]}];

if(parsedParameterName){
return [...prev, {...cmd, value: props.command.parsedParameters[parsedParameterName]}];
}
else if(cmd.default_value){
return [...prev, {...cmd, value: cmd.default_value.toLowerCase() === "true"}];
}else{
return [...prev, {...cmd, value: false}];
}
case "String":
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, value: props.command.parsedParameters[cmd.name]}];
if(parsedParameterName){
return [...prev, {...cmd, value: props.command.parsedParameters[parsedParameterName]}];
}else{
return [...prev, {...cmd, value: cmd.default_value}];
}
case "Number":
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, value: props.command.parsedParameters[cmd.name]}];
if(parsedParameterName){
return [...prev, {...cmd, value: props.command.parsedParameters[parsedParameterName]}];
}else{
return [...prev, {...cmd, value: cmd.default_value === "" ? 0 : parseInt(cmd.default_value)}];
}
case "Array":
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, value: props.command.parsedParameters[cmd.name]}];
if(parsedParameterName){
return [...prev, {...cmd, value: props.command.parsedParameters[parsedParameterName]}];
}else if(cmd.default_value.length > 0){
return [...prev, {...cmd, value: JSON.parse(cmd.default_value)}];
}else{
return [...prev, {...cmd, value: []}];
}
case "TypedArray":
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, value: props.command.parsedParameters[cmd.name]}];
if(parsedParameterName){
return [...prev, {...cmd, value: props.command.parsedParameters[parsedParameterName]}];
}else if(cmd.default_value.length > 0){
return [...prev, {...cmd, value: JSON.parse(cmd.default_value)}];
}else{
Expand Down Expand Up @@ -538,16 +552,19 @@ export function TaskParametersDialog(props) {
else{defaultV = choices[0];}
}
}
if(cmd.name in props.command.parsedParameters){
return [...prev, {...cmd, choices: choices, value: props.command.parsedParameters[cmd.name]}];
if(parsedParameterName){
return [...prev, {...cmd, choices: choices, value: props.command.parsedParameters[parsedParameterName]}];
}else{
return [...prev, {...cmd, choices: choices, default_value: defaultV, value: defaultV}];
}
case "File":
return [...prev, {...cmd, value: {} }];
case "CredentialJson":
if (loadedCredentialsLoading.credential.length > 0){
if(cmd.value === "" || (typeof(cmd.value) === Object && Object.keys(cmd.value).length === 0) || cmd.value === undefined){
if(parsedParameterName){
cmd.value = props.command.parsedParameters[parsedParameterName];
}
else if(cmd.value === "" || (typeof(cmd.value) === Object && Object.keys(cmd.value).length === 0) || cmd.value === undefined){
cmd.value = loadedCredentialsLoading.credential[0];
}
return [...prev, {...cmd, choices: loadedCredentialsLoading.credential}];
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.15";
export const mythicUIVersion = "0.1.57";
export const mythicUIVersion = "0.1.58";

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.0af2f732.js",
"main.js": "/new/static/js/main.86a58adf.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.0af2f732.js.map": "/new/static/js/main.0af2f732.js.map"
"main.86a58adf.js.map": "/new/static/js/main.86a58adf.js.map"
},
"entrypoints": [
"static/css/main.00d51b79.css",
"static/js/main.0af2f732.js"
"static/js/main.86a58adf.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.0af2f732.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.86a58adf.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 fdcfe27

Please sign in to comment.