Skip to content

Commit

Permalink
fixing UI parsing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Aug 19, 2024
1 parent d59df9a commit e6ada84
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 49 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.2.27] - 2024-08-19

### Changed

- Fixed a bug in args parsing via the command line that would lose an argument
- Updated the text display for file browser when needing to list out file contents

## [0.2.26] - 2024-08-15

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
}catch(error){
console.log(error);
}


for(let j = 0; j < currentGroups.length; j++){
if(treeRootDataRef.current[currentGroups[j]] === undefined){
treeRootDataRef.current[currentGroups[j]] = {};
Expand Down Expand Up @@ -302,8 +300,9 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
} else {
// we need to merge data in because we already have some info
let existingData = treeRootDataRef.current[currentGroups[j]][data.data.mythictree_stream[i]["host"]][data.data.mythictree_stream[i]["full_path_text"]];
if(existingData.success === null || !existingData.success){
if( (existingData.success === null || !existingData.success) && data.data.mythictree_stream[i].success !== null){
existingData.success = data.data.mythictree_stream[i].success;
existingData.task_id = data.data.mythictree_stream[i].task_id;
}
existingData.comment += data.data.mythictree_stream[i].comment;
existingData.tags = [...existingData.tags, ...data.data.mythictree_stream[i].tags];
Expand Down Expand Up @@ -383,8 +382,9 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
} else {
// we need to merge data in because we already have some info
let existingData = treeRootDataRef.current[currentGroups[j]][mythictree[i]["host"]][mythictree[i]["full_path_text"]];
if(existingData.success === null || !existingData.success){
if( (existingData.success === null || !existingData.success) && mythictree[i].success !== null){
existingData.success = mythictree[i].success;
existingData.task_id = mythictree[i].task_id;
}
existingData.comment += mythictree[i].comment;
existingData.tags = [...existingData.tags, ...mythictree[i].tags];
Expand All @@ -397,6 +397,10 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
})
existingData.filemeta = [...existingData.filemeta, ...newfileData]
treeRootDataRef.current[currentGroups[j]][mythictree[i]["host"]][mythictree[i]["full_path_text"]] = {...existingData};
if(selectedFolderData.group === currentGroups[j] && selectedFolderData.host === mythictree[i]["host"] &&
selectedFolderData.full_path_text === mythictree[i]["full_path_text"]){
setSelectedFolderData({...existingData, group: currentGroups[j]});
}
}
}
}
Expand Down Expand Up @@ -424,7 +428,7 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
//console.log("just set treeAdjMtx, about to close backdrop")
setBackdropOpen(false);
if(data.self.length > 0){
setSelectedFolderData({...selectedFolderData, task_id: data.self[0].task_id, success: data.self[0].success});
//setSelectedFolderData({...selectedFolderData, task_id: data.self[0].task_id, success: data.self[0].success});
// this path exists, let's see if we have data for it and if the user wants us to auto-issue an ls for the path
let newAllData = Object.keys(newMatrix[selectedFolderData.group]?.[selectedFolderData.host]?.[data.self[0].full_path_text] || {});
if(autoTaskLsOnEmptyDirectoriesRef.current){
Expand Down Expand Up @@ -472,9 +476,13 @@ export const CallbacksTabsFileBrowserPanel = ({ index, value, tabInfo, me }) =>
localSelectedToken.current = token;
}
const onListFilesButton = ({ fullPath, callback_id, callback_display_id, token }) => {
let path = fullPath;
if(path === ""){
path = ".";
}
taskingData.current = ({
"token": token,
"parameters": {path: fullPath, full_path: fullPath, host: selectedFolderData.host, file: ""},
"parameters": {path: path, full_path: path, host: selectedFolderData.host, file: ""},
"ui_feature": "file_browser:list", callback_id, callback_display_id});
setOpenTaskingButton(true);
};
Expand Down Expand Up @@ -741,19 +749,19 @@ const FileBrowserTableTop = ({
fetchFolderData(history[historyIndex - 1], true);
}
const onLocalListFilesButton = () => {
if (fullPath === '') {
snackActions.warning('Must provide a path to list');
return;
let tempPath = fullPath;
if (tempPath === "") {
tempPath = ".";
}
if(fullPath.length > 1){
if(fullPath[fullPath.length-1] === "/" || fullPath[fullPath.length-1] === "\\"){
let newFullPath = fullPath.slice(0, fullPath.length-1);
if(tempPath.length > 1){
if(tempPath[tempPath.length-1] === "/" || tempPath[tempPath.length-1] === "\\"){
let newFullPath = tempPath.slice(0, tempPath.length-1);
setFullPath(newFullPath);
onListFilesButton({ fullPath: newFullPath, token: selectedToken.current });
return
}
}
onListFilesButton({ fullPath, token: selectedToken.current });
onListFilesButton({ fullPath: tempPath, token: selectedToken.current });
};
const onLocalUploadFileButton = () => {
onUploadFileButton({ fullPath, token: selectedToken.current });
Expand Down Expand Up @@ -812,8 +820,7 @@ const FileBrowserTableTop = ({
endAdornment: (
<React.Fragment>
<MythicStyledTooltip title={`Task current callback (${tabInfo["displayID"]}) to list contents`}>
<IconButton style={{ padding: '0 0px 0 0 ' }}

<IconButton style={{ padding: '3px' }}
onClick={onLocalListFilesButton}
size="large">
<RefreshIcon color='info' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ export const CallbacksTabsFileBrowserTable = (props) => {
[sortedData, props.onTaskRowAction, filterOptions, columnVisibility, props.showDeletedFiles]
);
const getDisplayFormat = () => {
if(sortedData.length > 0 || props?.selectedFolderData?.success){
if(sortedData.length === 0 && props?.selectedFolderData?.success === false){
return "showTask";
}else if(sortedData.length > 0 || props?.selectedFolderData?.success){
return "normal";
} else if(sortedData.length === 0 && props?.selectedFolderData?.metadata?.has_children && props?.selectedFolderData?.success === null){
return "fetchLocal";
}else if(sortedData.length === 0 && !props?.selectedFolderData?.metadata?.has_children && props?.selectedFolderData?.success === null) {
return "fetchRemote";
}else if(sortedData.length === 0 && props?.selectedFolderData?.success === false){
return "showTask";
} else if(sortedData.length === 0){
}else if(sortedData.length === 0){
return "fetchRemote";
} else {
return "normal";
Expand Down Expand Up @@ -567,32 +567,62 @@ export const CallbacksTabsFileBrowserTable = (props) => {
onRowClick={onRowClick}
/>
}
{displayFormat === "normal" && props?.selectedFolderData?.success === null &&
<div style={{overflowY: "hidden", flexGrow: 1}}>
<div style={{
position: "absolute",
left: "35%",
top: "40%",
borderRadius: "4px",
border: "1px solid black",
padding: "5px",
backgroundColor: "rgba(37,37,37,0.92)", color: "white",
}}>
{"Only PARTIAL data has been collected for this path. "}<br/>
{"Task this callback to list the contents"}
<IconButton style={{margin: 0, padding: 0, marginRight: "10px"}}
onClick={props.onListFilesButtonFromTableWithNoEntries}>
<RefreshIcon color={"info"} fontSize={"large"}
style={{display: "inline-block",}}/>
</IconButton>
</div>
</div>
}
{displayFormat === "fetchLocal" &&
<div style={{overflowY: "hidden", flexGrow: 1}}>
<div style={{
position: "absolute",
left: "35%",
top: "40%"
}}>
{"Some data exists for this path, but isn't loaded into the UI. "}
<br/>
{"Click the folder icon to fetch data from the database."}
</div>
<div style={{
position: "absolute",
left: "35%",
top: "40%",
borderRadius: "4px",
border: "1px solid black",
padding: "5px",
backgroundColor: "rgba(37,37,37,0.92)", color: "white",
}}>
{"Some data exists for this path, but isn't loaded into the UI. "}
<br/>
{"Click the folder icon to fetch data from the database."}
</div>
</div>
}
{displayFormat === "fetchRemote" &&
<div style={{overflowY: "hidden", flexGrow: 1}}>
<div style={{
position: "absolute",
left: "35%",
top: "40%"
top: "40%",
borderRadius: "4px",
border: "1px solid black",
padding: "5px",
backgroundColor: "rgba(37,37,37,0.92)", color: "white",
}}>
{"No data has been collected for this path. "}
<div style={{display: "flex", alignContent: "center"}}>
<div style={{display: "flex", alignItems: "center"}}>
{"Task this callback to list the contents"}
<IconButton style={{margin: 0, padding: 0, marginRight: "10px"}} onClick={props.onListFilesButtonFromTableWithNoEntries} >
<RefreshIcon color={"info"} style={{ display: "inline-block",}} />
<RefreshIcon color={"info"} fontSize={"large"}
style={{ display: "inline-block",}} />
</IconButton>
{"Task this callback to list the contents"}
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,13 @@ export const CallbacksTabsProcessBrowserPanel = ({index, value, tabInfo, me}) =>

<div style={{width: "100%", display: "flex", flexDirection: "column", flexGrow: 1}}>
<Backdrop open={backdropOpen} style={{zIndex: 2, position: "absolute",}} invisible={false}>
<div style={{backgroundColor: "#000000ab", color: "white", alignItems: "center",
display: "flex", flexDirection: "column", borderRadius: "4px"}}>
<div style={{
borderRadius: "4px",
border: "1px solid black",
padding: "5px",
backgroundColor: "rgba(37,37,37,0.92)", color: "white",
alignItems: "center",
display: "flex", flexDirection: "column"}}>
<CircularProgress color="inherit" />
<Typography variant={"h5"}>
Gathering Processes from database for {selectedHost}...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ export function CallbacksTabsTaskingInputPreMemo(props){
} else {
// we don't have this as a named argument, so we'll process it as a positional one
result["_"].push(value);
current_argument = "";
current_argument_type = "";
}
} else {
// we have a named argument that we just saw, so interpret this as that argument's value
Expand Down Expand Up @@ -1003,7 +1005,8 @@ export function CallbacksTabsTaskingInputPreMemo(props){
unSatisfiedArguments.push(groupParameters[i]);
}
}
// now iterate over the unsatisfied arguments and add in the positional paramters
// now iterate over the unsatisfied arguments and add in the positional parameters
//console.log("unsatisfiedParameters", unSatisfiedArguments)
for(let i = 0; i < unSatisfiedArguments.length; i++){
// we cut this short by one so that the last unSatisifedArgument can do a greedy matching for the rest of what was supplied
// this parameter hasn't been supplied yet, check if we have any positional parameters in parsedCopy["_"]
Expand Down Expand Up @@ -1057,7 +1060,7 @@ export function CallbacksTabsTaskingInputPreMemo(props){
break;
}
}

//console.log("unsatisfied filled, but still some args", JSON.parse(JSON.stringify(parsedCopy)))
if(unSatisfiedArguments.length > 0 && parsedCopy["_"].length > 0){
//parsedCopy["_"] = parsedCopy["_"].map( c => typeof(c) === "string" && c.includes(" ") ? "\"" + c + "\"" : c);
let temp = ""; //parsedCopy["_"].join(" ");
Expand Down Expand Up @@ -1088,12 +1091,11 @@ export function CallbacksTabsTaskingInputPreMemo(props){
}
temp = temp.trim();
}

switch(unSatisfiedArguments[unSatisfiedArguments.length -1]["parameter_type"]){
case "ChooseOne":
case "ChooseOneCustom":
case "String":
parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]] = temp;
parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]] += " " + temp;
break;
case "Number":
try{
Expand Down Expand Up @@ -1122,7 +1124,8 @@ export function CallbacksTabsTaskingInputPreMemo(props){
case "TypedArray":
case "FileMultiple":
case "ChooseMultiple":
parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]] = parsedCopy["_"];
parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]] =
[parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]], ...parsedCopy["_"]];
break;
default:
parsedCopy[unSatisfiedArguments[unSatisfiedArguments.length -1]["cli_name"]] = temp;
Expand Down Expand Up @@ -1166,7 +1169,7 @@ export function CallbacksTabsTaskingInputPreMemo(props){
if(parsed === undefined){
return;
}
parsed["_"].unshift(cmd);
parsed = {...parsed};
//console.log(message, parsed);
cmdGroupName = determineCommandGroupName(cmd, parsed);
if(cmdGroupName !== undefined){
Expand All @@ -1177,6 +1180,7 @@ export function CallbacksTabsTaskingInputPreMemo(props){
}

if(cmd.commandparameters.length > 0){
parsed["_"].unshift(cmd);
parsedWithPositionalParameters = fillOutPositionalArguments(cmd, parsed, cmdGroupName);
//console.log(parsedWithPositionalParameters);
if(parsedWithPositionalParameters === undefined){
Expand Down
2 changes: 1 addition & 1 deletion MythicReactUI/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {snackActions} from './components/utilities/Snackbar';
import jwt_decode from 'jwt-decode';
import {meState} from './cache';

export const mythicUIVersion = "0.2.26";
export const mythicUIVersion = "0.2.27";

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.7e143bf2.css",
"main.js": "/new/static/js/main.46cc65bc.js",
"main.js": "/new/static/js/main.ec7d1bfb.js",
"static/media/mythic-red.png": "/new/static/media/mythic-red.203468a4e5240d239aa0.png",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.7e143bf2.css.map": "/new/static/css/main.7e143bf2.css.map",
"main.46cc65bc.js.map": "/new/static/js/main.46cc65bc.js.map"
"main.ec7d1bfb.js.map": "/new/static/js/main.ec7d1bfb.js.map"
},
"entrypoints": [
"static/css/main.7e143bf2.css",
"static/js/main.46cc65bc.js"
"static/js/main.ec7d1bfb.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.46cc65bc.js"></script><link href="/new/static/css/main.7e143bf2.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.ec7d1bfb.js"></script><link href="/new/static/css/main.7e143bf2.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 e6ada84

Please sign in to comment.