From 4709bae0ee4c209c527091bdb7d49bf8b57d166d Mon Sep 17 00:00:00 2001 From: "M. Mert Yildiran" Date: Wed, 25 Aug 2021 00:07:05 +0300 Subject: [PATCH] Bring in the necessary changes from f74a52d4dcba55aca0917f9deaf7da55a20a6f8e --- README.md | 12 ++++ agent/main.go | 13 +++- ui/src/App.sass | 4 +- ui/src/App.tsx | 6 +- .../{HarEntriesList.tsx => EntriesList.tsx} | 34 +++++----- ...HarEntryDetailed.tsx => EntryDetailed.tsx} | 37 +++++----- .../EntrySections.module.sass} | 2 +- .../EntrySections.tsx} | 68 +++++++++---------- .../EntryViewer.module.sass} | 6 +- .../EntryViewer.tsx} | 18 ++--- .../EntryListItem.module.sass} | 2 +- .../EntryListItem.tsx} | 28 ++++---- .../{HarFilters.tsx => Filters.tsx} | 14 ++-- ui/src/components/HarPaging.tsx | 27 -------- .../{HarPage.tsx => TrafficPage.tsx} | 47 +++++++------ ui/src/components/{ => UI}/Checkbox.tsx | 0 .../{ => UI}/CollapsibleContainer.tsx | 4 +- ui/src/components/{ => UI}/EndpointPath.tsx | 0 .../components/{ => UI}/FancyTextDisplay.tsx | 2 +- .../FilterSelect.tsx} | 8 +-- ui/src/components/{ => UI}/Protocol.tsx | 0 ui/src/components/{ => UI}/Select.tsx | 2 +- ui/src/components/{ => UI}/StatusBar.tsx | 0 ui/src/components/{ => UI}/StatusCode.tsx | 4 +- .../SyntaxHighlighter/highlighterStyle.ts | 0 .../{ => UI}/SyntaxHighlighter/index.scss | 0 .../{ => UI}/SyntaxHighlighter/index.tsx | 0 ui/src/components/{ => UI}/Tabs.tsx | 2 +- ui/src/components/{ => UI}/Tooltip.tsx | 0 .../{ => UI}/style/CollapsibleContainer.sass | 0 .../{ => UI}/style/EndpointPath.module.sass | 0 .../{ => UI}/style/FancyTextDisplay.sass | 0 .../UI/style/FilterSelect.module.sass | 3 + .../{ => UI}/style/Protocol.module.sass | 2 - .../{ => UI}/style/Select.module.sass | 0 .../components/{ => UI}/style/StatusBar.sass | 4 +- .../{ => UI}/style/StatusCode.module.sass | 2 +- .../{ => UI}/style/misc.module.sass | 4 +- .../assets/{union.svg => downImg.svg} | 0 ...st.module.sass => EntriesList.module.sass} | 2 +- ...ilters.module.sass => Filters.module.sass} | 2 +- .../style/HARFilterSelect.module.sass | 3 - .../style/HarEntryDetailed.module.sass | 7 -- ui/src/components/style/HarPaging.module.sass | 16 ----- .../style/{HarPage.sass => TrafficPage.sass} | 26 +++---- ui/src/components/utils.ts | 35 ---------- ui/src/hooks/use-toggle.ts | 10 --- ui/src/index.sass | 2 +- .../style => }/variables.module.scss | 0 49 files changed, 187 insertions(+), 271 deletions(-) rename ui/src/components/{HarEntriesList.tsx => EntriesList.tsx} (78%) rename ui/src/components/{HarEntryDetailed.tsx => EntryDetailed.tsx} (57%) rename ui/src/components/{HarEntryViewer/HAREntrySections.module.sass => EntryDetailed/EntrySections.module.sass} (98%) rename ui/src/components/{HarEntryViewer/HAREntrySections.tsx => EntryDetailed/EntrySections.tsx} (77%) rename ui/src/components/{HarEntryViewer/HAREntryViewer.module.sass => EntryDetailed/EntryViewer.module.sass} (95%) rename ui/src/components/{HarEntryViewer/HAREntryViewer.tsx => EntryDetailed/EntryViewer.tsx} (73%) rename ui/src/components/{style/HarEntry.module.sass => EntryListItem/EntryListItem.module.sass} (97%) rename ui/src/components/{HarEntry.tsx => EntryListItem/EntryListItem.tsx} (85%) rename ui/src/components/{HarFilters.tsx => Filters.tsx} (89%) delete mode 100644 ui/src/components/HarPaging.tsx rename ui/src/components/{HarPage.tsx => TrafficPage.tsx} (84%) rename ui/src/components/{ => UI}/Checkbox.tsx (100%) rename ui/src/components/{ => UI}/CollapsibleContainer.tsx (95%) rename ui/src/components/{ => UI}/EndpointPath.tsx (100%) rename ui/src/components/{ => UI}/FancyTextDisplay.tsx (97%) rename ui/src/components/{HARFilterSelect.tsx => UI/FilterSelect.tsx} (69%) rename ui/src/components/{ => UI}/Protocol.tsx (100%) rename ui/src/components/{ => UI}/Select.tsx (97%) rename ui/src/components/{ => UI}/StatusBar.tsx (100%) rename ui/src/components/{ => UI}/StatusCode.tsx (90%) rename ui/src/components/{ => UI}/SyntaxHighlighter/highlighterStyle.ts (100%) rename ui/src/components/{ => UI}/SyntaxHighlighter/index.scss (100%) rename ui/src/components/{ => UI}/SyntaxHighlighter/index.tsx (100%) rename ui/src/components/{ => UI}/Tabs.tsx (97%) rename ui/src/components/{ => UI}/Tooltip.tsx (100%) rename ui/src/components/{ => UI}/style/CollapsibleContainer.sass (100%) rename ui/src/components/{ => UI}/style/EndpointPath.module.sass (100%) rename ui/src/components/{ => UI}/style/FancyTextDisplay.sass (100%) create mode 100644 ui/src/components/UI/style/FilterSelect.module.sass rename ui/src/components/{ => UI}/style/Protocol.module.sass (94%) rename ui/src/components/{ => UI}/style/Select.module.sass (100%) rename ui/src/components/{ => UI}/style/StatusBar.sass (91%) rename ui/src/components/{ => UI}/style/StatusCode.module.sass (90%) rename ui/src/components/{ => UI}/style/misc.module.sass (90%) rename ui/src/components/assets/{union.svg => downImg.svg} (100%) rename ui/src/components/style/{HarEntriesList.module.sass => EntriesList.module.sass} (97%) rename ui/src/components/style/{HarFilters.module.sass => Filters.module.sass} (94%) delete mode 100644 ui/src/components/style/HARFilterSelect.module.sass delete mode 100644 ui/src/components/style/HarEntryDetailed.module.sass delete mode 100644 ui/src/components/style/HarPaging.module.sass rename ui/src/components/style/{HarPage.sass => TrafficPage.sass} (84%) delete mode 100644 ui/src/components/utils.ts delete mode 100644 ui/src/hooks/use-toggle.ts rename ui/src/{components/style => }/variables.module.scss (100%) diff --git a/README.md b/README.md index 7d74038a0..7dafbe592 100644 --- a/README.md +++ b/README.md @@ -159,3 +159,15 @@ Such validation may test response for specific JSON fields, headers, etc. Please see [API RULES](docs/POLICY_RULES.md) page for more details and syntax. + +## How to Run local UI + +- run from mizu/agent `go run main.go --hars-read --hars-dir ` + +- copy Har files into the folder from last command + +- change `MizuWebsocketURL` and `apiURL` in `api.js` file + +- run from mizu/ui - `npm run start` + +- open browser on `localhost:3000` diff --git a/agent/main.go b/agent/main.go index 055289202..79a55aaeb 100644 --- a/agent/main.go +++ b/agent/main.go @@ -32,6 +32,8 @@ var apiServerMode = flag.Bool("api-server", false, "Run in API server mode with var standaloneMode = flag.Bool("standalone", false, "Run in standalone tapper and API mode") var apiServerAddress = flag.String("api-server-address", "", "Address of mizu API server") var namespace = flag.String("namespace", "", "Resolve IPs if they belong to resources in this namespace (default is all)") +var harsReaderMode = flag.Bool("hars-read", false, "Run in hars-read mode") +var harsDir = flag.String("hars-dir", "", "Directory to read hars from") var extensions []*tapApi.Extension // global var extensionsMap map[string]*tapApi.Extension // global @@ -43,8 +45,8 @@ func main() { hostMode := os.Getenv(shared.HostModeEnvVar) == "1" tapOpts := &tap.TapOpts{HostMode: hostMode} - if !*tapperMode && !*apiServerMode && !*standaloneMode { - panic("One of the flags --tap, --api or --standalone must be provided") + if !*tapperMode && !*apiServerMode && !*standaloneMode && !*harsReaderMode { + panic("One of the flags --tap, --api or --standalone or --hars-read must be provided") } if *standaloneMode { @@ -90,6 +92,13 @@ func main() { go api.StartReadingEntries(socketHarOutChannel, nil, extensionsMap) hostApi(socketHarOutChannel) + } else if *harsReaderMode { + socketHarOutChannel := make(chan *tapApi.OutputChannelItem, 1000) + // filteredHarChannel := make(chan *tap.OutputChannelItem) + + // go filterHarItems(socketHarOutChannel, filteredHarChannel, getTrafficFilteringOptions()) + go api.StartReadingEntries(socketHarOutChannel, harsDir, extensionsMap) + hostApi(nil) } signalChan := make(chan os.Signal, 1) diff --git a/ui/src/App.sass b/ui/src/App.sass index 629011eac..c9c6ae28a 100644 --- a/ui/src/App.sass +++ b/ui/src/App.sass @@ -1,4 +1,4 @@ -@import 'components/style/variables.module' +@import './variables.module' .mizuApp background-color: $main-background-color @@ -22,4 +22,4 @@ margin-left: 10px font-size: 11px font-weight: bold - color: $light-blue-color \ No newline at end of file + color: $light-blue-color diff --git a/ui/src/App.tsx b/ui/src/App.tsx index ed8eeab65..92cf64d9a 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -2,8 +2,8 @@ import React, {useEffect, useState} from 'react'; import './App.sass'; import logo from './components/assets/Mizu-logo.svg'; import {Button, Snackbar} from "@material-ui/core"; -import {HarPage} from "./components/HarPage"; -import Tooltip from "./components/Tooltip"; +import {TrafficPage} from "./components/TrafficPage"; +import Tooltip from "./components/UI/Tooltip"; import {makeStyles} from "@material-ui/core/styles"; import MuiAlert from '@material-ui/lab/Alert'; import Api from "./helpers/api"; @@ -116,7 +116,7 @@ const App = () => { } - + setUserDismissedTLSWarning(true)} severity="warning"> Mizu is detecting TLS traffic{addressesWithTLS.size ? ` (directed to ${Array.from(addressesWithTLS).join(", ")})` : ''}, this type of traffic will not be displayed. diff --git a/ui/src/components/HarEntriesList.tsx b/ui/src/components/EntriesList.tsx similarity index 78% rename from ui/src/components/HarEntriesList.tsx rename to ui/src/components/EntriesList.tsx index 48799a845..6b1ae69f9 100644 --- a/ui/src/components/HarEntriesList.tsx +++ b/ui/src/components/EntriesList.tsx @@ -1,13 +1,13 @@ -import {HarEntry} from "./HarEntry"; -import React, {useCallback, useEffect, useMemo, useState} from "react"; -import styles from './style/HarEntriesList.module.sass'; +import {EntryItem} from "./EntryListItem/EntryListItem"; +import React, {useCallback, useEffect, useMemo, useRef, useState} from "react"; +import styles from './style/EntriesList.module.sass'; import spinner from './assets/spinner.svg'; import ScrollableFeed from "react-scrollable-feed"; -import {StatusType} from "./HarFilters"; +import {StatusType} from "./Filters"; import Api from "../helpers/api"; -import uninon from "./assets/union.svg"; +import down from "./assets/downImg.svg"; -interface HarEntriesListProps { +interface EntriesListProps { entries: any[]; setEntries: (entries: any[]) => void; focusedEntryId: string; @@ -32,11 +32,13 @@ enum FetchOperator { const api = new Api(); -export const HarEntriesList: React.FC = ({entries, setEntries, focusedEntryId, setFocusedEntryId, connectionOpen, noMoreDataTop, setNoMoreDataTop, noMoreDataBottom, setNoMoreDataBottom, methodsFilter, statusFilter, pathFilter, listEntryREF, onScrollEvent, scrollableList}) => { +export const EntriesList: React.FC = ({entries, setEntries, focusedEntryId, setFocusedEntryId, connectionOpen, noMoreDataTop, setNoMoreDataTop, noMoreDataBottom, setNoMoreDataBottom, methodsFilter, statusFilter, pathFilter, listEntryREF, onScrollEvent, scrollableList}) => { const [loadMoreTop, setLoadMoreTop] = useState(false); const [isLoadingTop, setIsLoadingTop] = useState(false); + const scrollableRef = useRef(null); + useEffect(() => { const list = document.getElementById('list').firstElementChild; list.addEventListener('scroll', (e) => { @@ -114,24 +116,20 @@ export const HarEntriesList: React.FC = ({entries, setEntri {isLoadingTop &&
spinner
} - onScrollEvent(isAtBottom)}> + onScrollEvent(isAtBottom)}> {noMoreDataTop && !connectionOpen &&
No more data available
} - {filteredEntries.map(entry => )} + {filteredEntries.map(entry => )} {!connectionOpen && !noMoreDataBottom &&
getNewEntries()}>Fetch more entries
}
diff --git a/ui/src/components/HarEntryDetailed.tsx b/ui/src/components/EntryDetailed.tsx similarity index 57% rename from ui/src/components/HarEntryDetailed.tsx rename to ui/src/components/EntryDetailed.tsx index 23b1471fa..2758133c6 100644 --- a/ui/src/components/HarEntryDetailed.tsx +++ b/ui/src/components/EntryDetailed.tsx @@ -1,10 +1,9 @@ import React from "react"; -import {singleEntryToHAR} from "./utils"; -import HAREntryViewer from "./HarEntryViewer/HAREntryViewer"; +import EntryViewer from "./EntryDetailed/EntryViewer"; import {makeStyles} from "@material-ui/core"; -import Protocol from "./Protocol" -import StatusCode from "./StatusCode"; -import {EndpointPath} from "./EndpointPath"; +import Protocol from "./UI/Protocol" +import StatusCode from "./UI/StatusCode"; +import {EndpointPath} from "./UI/EndpointPath"; const useStyles = makeStyles(() => ({ entryTitle: { @@ -27,34 +26,32 @@ const useStyles = makeStyles(() => ({ } })); -interface HarEntryDetailedProps { - harEntry: any; - classes?: any; +interface EntryDetailedProps { + entryData: any } export const formatSize = (n: number) => n > 1000 ? `${Math.round(n / 1000)}KB` : `${n} B`; -const HarEntryTitle: React.FC = ({protocol, har}) => { +const EntryTitle: React.FC = ({protocol, data}) => { const classes = useStyles(); - const {log: {entries}} = har; - const {response} = JSON.parse(entries[0].entry); + console.log("data:", data) + const {response} = JSON.parse(data.entry); return
{response.payload &&
{formatSize(response.payload.bodySize)}
} -
{'rulesMatched' in entries[0] ? entries[0].rulesMatched?.length : '0'} Rules Applied
+
{'rulesMatched' in data ? data.rulesMatched?.length : '0'} Rules Applied
; }; -const HarEntrySummary: React.FC = ({har}) => { +const EntrySummary: React.FC = ({data}) => { const classes = useStyles(); - const {log: {entries}} = har; - const {response, request} = JSON.parse(entries[0].entry); + const {response, request} = JSON.parse(data.entry); return
{response?.payload && response.payload?.details && "status" in response.payload.details &&
@@ -66,14 +63,12 @@ const HarEntrySummary: React.FC = ({har}) => {
; }; -export const HAREntryDetailed: React.FC = ({classes, harEntry}) => { - const har = singleEntryToHAR(harEntry.data); - +export const EntryDetailed: React.FC = ({entryData}) => { return <> - - {har && } + + {entryData.data && } <> - {har && } + {entryData.data && } }; diff --git a/ui/src/components/HarEntryViewer/HAREntrySections.module.sass b/ui/src/components/EntryDetailed/EntrySections.module.sass similarity index 98% rename from ui/src/components/HarEntryViewer/HAREntrySections.module.sass rename to ui/src/components/EntryDetailed/EntrySections.module.sass index c4b58cd5f..f6f16c96f 100644 --- a/ui/src/components/HarEntryViewer/HAREntrySections.module.sass +++ b/ui/src/components/EntryDetailed/EntrySections.module.sass @@ -1,4 +1,4 @@ -@import '../style/variables.module' +@import '../../variables.module' .title display: flex diff --git a/ui/src/components/HarEntryViewer/HAREntrySections.tsx b/ui/src/components/EntryDetailed/EntrySections.tsx similarity index 77% rename from ui/src/components/HarEntryViewer/HAREntrySections.tsx rename to ui/src/components/EntryDetailed/EntrySections.tsx index c1ba4538a..38dea2e79 100644 --- a/ui/src/components/HarEntryViewer/HAREntrySections.tsx +++ b/ui/src/components/EntryDetailed/EntrySections.tsx @@ -1,17 +1,17 @@ -import styles from "./HAREntrySections.module.sass"; +import styles from "./EntrySections.module.sass"; import React, {useState} from "react"; -import {SyntaxHighlighter} from "../SyntaxHighlighter/index"; -import CollapsibleContainer from "../CollapsibleContainer"; -import FancyTextDisplay from "../FancyTextDisplay"; -import Checkbox from "../Checkbox"; +import {SyntaxHighlighter} from "../UI/SyntaxHighlighter/index"; +import CollapsibleContainer from "../UI/CollapsibleContainer"; +import FancyTextDisplay from "../UI/FancyTextDisplay"; +import Checkbox from "../UI/Checkbox"; import ProtobufDecoder from "protobuf-decoder"; -interface HAREntryViewLineProps { +interface EntryViewLineProps { label: string; value: number | string; } -const HAREntryViewLine: React.FC = ({label, value}) => { +const EntryViewLine: React.FC = ({label, value}) => { return (label && value && {label} @@ -27,13 +27,13 @@ const HAREntryViewLine: React.FC = ({label, value}) => { } -interface HAREntrySectionCollapsibleTitleProps { +interface EntrySectionCollapsibleTitleProps { title: string, color: string, isExpanded: boolean, } -const HAREntrySectionCollapsibleTitle: React.FC = ({title, color, isExpanded}) => { +const EntrySectionCollapsibleTitle: React.FC = ({title, color, isExpanded}) => { return
{isExpanded ? '-' : '+'} @@ -42,31 +42,31 @@ const HAREntrySectionCollapsibleTitle: React.FC } -interface HAREntrySectionContainerProps { +interface EntrySectionContainerProps { title: string, color: string, } -export const HAREntrySectionContainer: React.FC = ({title, color, children}) => { +export const EntrySectionContainer: React.FC = ({title, color, children}) => { const [expanded, setExpanded] = useState(true); return setExpanded(!expanded)} - title={} + title={} > {children} } -interface HAREntryBodySectionProps { +interface EntryBodySectionProps { content: any, color: string, encoding?: string, contentType?: string, } -export const HAREntryBodySection: React.FC = ({ +export const EntryBodySection: React.FC = ({ color, content, encoding, @@ -104,11 +104,11 @@ export const HAREntryBodySection: React.FC = ({ } return - {content && content?.length > 0 && + {content && content?.length > 0 && - - + +
@@ -124,35 +124,35 @@ export const HAREntryBodySection: React.FC = ({ code={formatTextBody(content)} language={content?.mimeType ? getLanguage(content.mimeType) : 'default'} /> -
} + }
} -interface HAREntrySectionProps { +interface EntrySectionProps { title: string, color: string, arrayToIterate: any[], } -export const HAREntryTableSection: React.FC = ({title, color, arrayToIterate}) => { +export const EntryTableSection: React.FC = ({title, color, arrayToIterate}) => { return { arrayToIterate && arrayToIterate.length > 0 ? - + - {arrayToIterate.map(({name, value}, index) => )}
-
: + : }
} -interface HAREntryPolicySectionProps { +interface EntryPolicySectionProps { service: string, title: string, color: string, @@ -162,13 +162,13 @@ interface HAREntryPolicySectionProps { } -interface HAREntryPolicySectionCollapsibleTitleProps { +interface EntryPolicySectionCollapsibleTitleProps { label: string; matched: string; isExpanded: boolean; } -const HAREntryPolicySectionCollapsibleTitle: React.FC = ({label, matched, isExpanded}) => { +const EntryPolicySectionCollapsibleTitle: React.FC = ({label, matched, isExpanded}) => { return
{isExpanded ? '-' : '+'} @@ -182,36 +182,36 @@ const HAREntryPolicySectionCollapsibleTitle: React.FC } -interface HAREntryPolicySectionContainerProps { +interface EntryPolicySectionContainerProps { label: string; matched: string; children?: any; } -export const HAREntryPolicySectionContainer: React.FC = ({label, matched, children}) => { +export const EntryPolicySectionContainer: React.FC = ({label, matched, children}) => { const [expanded, setExpanded] = useState(false); return setExpanded(!expanded)} - title={} + title={} > {children} } -export const HAREntryTablePolicySection: React.FC = ({service, title, color, response, latency, arrayToIterate}) => { +export const EntryTablePolicySection: React.FC = ({service, title, color, response, latency, arrayToIterate}) => { // const base64ToJson = response.content.mimeType === "application/json; charset=utf-8" ? JSON.parse(Buffer.from(response.content.text, "base64").toString()) : {}; return { arrayToIterate && arrayToIterate.length > 0 ? <> - + {arrayToIterate.map(({rule, matched}, index) => { return ( - = latency : true)? "Success" : "Failure"}> + = latency : true)? "Success" : "Failure"}> { <> { @@ -251,14 +251,14 @@ export const HAREntryTablePolicySection: React.FC = } } - + ) } ) }
-
+ : }
diff --git a/ui/src/components/HarEntryViewer/HAREntryViewer.module.sass b/ui/src/components/EntryDetailed/EntryViewer.module.sass similarity index 95% rename from ui/src/components/HarEntryViewer/HAREntryViewer.module.sass rename to ui/src/components/EntryDetailed/EntryViewer.module.sass index 1dc344781..fd8c882da 100644 --- a/ui/src/components/HarEntryViewer/HAREntryViewer.module.sass +++ b/ui/src/components/EntryDetailed/EntryViewer.module.sass @@ -1,6 +1,6 @@ -@import "../style/variables.module" +@import "../../variables.module" -.harEntry +.Entry font-family: "Source Sans Pro", Lucida Grande, Tahoma, sans-serif height: 100% width: 100% @@ -57,4 +57,4 @@ text-decoration: none margin-bottom: .5rem overflow-wrap: anywhere - padding: 5px 0 \ No newline at end of file + padding: 5px 0 diff --git a/ui/src/components/HarEntryViewer/HAREntryViewer.tsx b/ui/src/components/EntryDetailed/EntryViewer.tsx similarity index 73% rename from ui/src/components/HarEntryViewer/HAREntryViewer.tsx rename to ui/src/components/EntryDetailed/EntryViewer.tsx index 1d623b6c6..59f16bed8 100644 --- a/ui/src/components/HarEntryViewer/HAREntryViewer.tsx +++ b/ui/src/components/EntryDetailed/EntryViewer.tsx @@ -1,7 +1,7 @@ import React, {useState} from 'react'; -import styles from './HAREntryViewer.module.sass'; -import Tabs from "../Tabs"; -import {HAREntryTableSection, HAREntryBodySection, HAREntryTablePolicySection} from "./HAREntrySections"; +import styles from './EntryViewer.module.sass'; +import Tabs from "../UI/Tabs"; +import {EntryTableSection, EntryBodySection, EntryTablePolicySection} from "./EntrySections"; const SectionsRepresentation: React.FC = ({data, color}) => { const sections = [] @@ -11,12 +11,12 @@ const SectionsRepresentation: React.FC = ({data, color}) => { switch (row.type) { case "table": sections.push( - + ) break; case "body": sections.push( - + ) break; default: @@ -49,7 +49,7 @@ const AutoRepresentation: React.FC = ({representation, color, isResponseMoc const {request, response} = JSON.parse(representation); - return
+ return
{
@@ -63,7 +63,7 @@ const AutoRepresentation: React.FC = ({representation, color, isResponseMoc } {currentTab === TABS[2].tab && {// FIXME: Fix here - } + } }
}
; @@ -76,8 +76,8 @@ interface Props { showTitle?: boolean; } -const HAREntryViewer: React.FC = ({representation, color, isResponseMocked, showTitle=true}) => { +const EntryViewer: React.FC = ({representation, color, isResponseMocked, showTitle=true}) => { return }; -export default HAREntryViewer; +export default EntryViewer; diff --git a/ui/src/components/style/HarEntry.module.sass b/ui/src/components/EntryListItem/EntryListItem.module.sass similarity index 97% rename from ui/src/components/style/HarEntry.module.sass rename to ui/src/components/EntryListItem/EntryListItem.module.sass index 2bed17dc5..0ee428182 100644 --- a/ui/src/components/style/HarEntry.module.sass +++ b/ui/src/components/EntryListItem/EntryListItem.module.sass @@ -1,4 +1,4 @@ -@import 'variables.module' +@import '../../variables.module' .row display: flex diff --git a/ui/src/components/HarEntry.tsx b/ui/src/components/EntryListItem/EntryListItem.tsx similarity index 85% rename from ui/src/components/HarEntry.tsx rename to ui/src/components/EntryListItem/EntryListItem.tsx index 5769bb664..529f65895 100644 --- a/ui/src/components/HarEntry.tsx +++ b/ui/src/components/EntryListItem/EntryListItem.tsx @@ -1,16 +1,16 @@ import React from "react"; -import styles from './style/HarEntry.module.sass'; -import StatusCode, {getClassification, StatusCodeClassification} from "./StatusCode"; -import Protocol, {ProtocolInterface} from "./Protocol" -import {EndpointPath} from "./EndpointPath"; -import ingoingIconSuccess from "./assets/ingoing-traffic-success.svg" -import ingoingIconFailure from "./assets/ingoing-traffic-failure.svg" -import ingoingIconNeutral from "./assets/ingoing-traffic-neutral.svg" -import outgoingIconSuccess from "./assets/outgoing-traffic-success.svg" -import outgoingIconFailure from "./assets/outgoing-traffic-failure.svg" -import outgoingIconNeutral from "./assets/outgoing-traffic-neutral.svg" +import styles from './EntryListItem.module.sass'; +import StatusCode, {getClassification, StatusCodeClassification} from "../UI/StatusCode"; +import Protocol, {ProtocolInterface} from "../UI/Protocol" +import {EndpointPath} from "../UI/EndpointPath"; +import ingoingIconSuccess from "../assets/ingoing-traffic-success.svg" +import ingoingIconFailure from "../assets/ingoing-traffic-failure.svg" +import ingoingIconNeutral from "../assets/ingoing-traffic-neutral.svg" +import outgoingIconSuccess from "../assets/outgoing-traffic-success.svg" +import outgoingIconFailure from "../assets/outgoing-traffic-failure.svg" +import outgoingIconNeutral from "../assets/outgoing-traffic-neutral.svg" -interface HAREntry { +interface Entry { protocol: ProtocolInterface, method?: string, summary: string, @@ -34,13 +34,13 @@ interface Rules { numberOfRules: number; } -interface HAREntryProps { - entry: HAREntry; +interface EntryProps { + entry: Entry; setFocusedEntryId: (id: string) => void; isSelected?: boolean; } -export const HarEntry: React.FC = ({entry, setFocusedEntryId, isSelected}) => { +export const EntryItem: React.FC = ({entry, setFocusedEntryId, isSelected}) => { const classification = getClassification(entry.status_code) let ingoingIcon; let outgoingIcon; diff --git a/ui/src/components/HarFilters.tsx b/ui/src/components/Filters.tsx similarity index 89% rename from ui/src/components/HarFilters.tsx rename to ui/src/components/Filters.tsx index 5dee2b564..c7188c2a5 100644 --- a/ui/src/components/HarFilters.tsx +++ b/ui/src/components/Filters.tsx @@ -1,10 +1,10 @@ import React from "react"; -import styles from './style/HarFilters.module.sass'; -import {HARFilterSelect} from "./HARFilterSelect"; +import styles from './style/Filters.module.sass'; +import {FilterSelect} from "./UI/FilterSelect"; import {TextField} from "@material-ui/core"; -import {ALL_KEY} from "./Select"; +import {ALL_KEY} from "./UI/Select"; -interface HarFiltersProps { +interface FiltersProps { methodsFilter: Array; setMethodsFilter: (methods: Array) => void; statusFilter: Array; @@ -13,7 +13,7 @@ interface HarFiltersProps { setPathFilter: (val: string) => void; } -export const HarFilters: React.FC = ({methodsFilter, setMethodsFilter, statusFilter, setStatusFilter, pathFilter, setPathFilter}) => { +export const Filters: React.FC = ({methodsFilter, setMethodsFilter, statusFilter, setStatusFilter, pathFilter, setPathFilter}) => { return
@@ -59,7 +59,7 @@ const MethodFilter: React.FC = ({methodsFilter, setMethodsFil } return - = ({statusFilter, setS } return - = ({showPageNumber=false}) => { - - return - { - // harStore.data.moveBack(); todo - }} alt="back"/> - {showPageNumber && - Page - {/*{numeral(harStore.data.currentPage).format(0, 0)}*/} //todo - - } - { - // harStore.data.moveNext(); todo - }} alt="next"/> - -}; \ No newline at end of file diff --git a/ui/src/components/HarPage.tsx b/ui/src/components/TrafficPage.tsx similarity index 84% rename from ui/src/components/HarPage.tsx rename to ui/src/components/TrafficPage.tsx index 3cf42d5ca..d2ec96dac 100644 --- a/ui/src/components/HarPage.tsx +++ b/ui/src/components/TrafficPage.tsx @@ -1,14 +1,14 @@ import React, {useEffect, useRef, useState} from "react"; -import {HarFilters} from "./HarFilters"; -import {HarEntriesList} from "./HarEntriesList"; +import {Filters} from "./Filters"; +import {EntriesList} from "./EntriesList"; import {makeStyles} from "@material-ui/core"; -import "./style/HarPage.sass"; -import styles from './style/HarEntriesList.module.sass'; -import {HAREntryDetailed} from "./HarEntryDetailed"; +import "./style/TrafficPage.sass"; +import styles from './style/EntriesList.module.sass'; +import {EntryDetailed} from "./EntryDetailed"; import playIcon from './assets/run.svg'; import pauseIcon from './assets/pause.svg'; -import variables from './style/variables.module.scss'; -import {StatusBar} from "./StatusBar"; +import variables from '../variables.module.scss'; +import {StatusBar} from "./UI/StatusBar"; import Api, {MizuWebsocketURL} from "../helpers/api"; const useLayoutStyles = makeStyles(() => ({ @@ -21,7 +21,7 @@ const useLayoutStyles = makeStyles(() => ({ background: variables.headerBackgoundColor }, - harViewer: { + viewer: { display: 'flex', overflowY: 'auto', height: "calc(100% - 70px)", @@ -36,20 +36,20 @@ enum ConnectionStatus { Paused } -interface HarPageProps { +interface TrafficPageProps { setAnalyzeStatus: (status: any) => void; onTLSDetected: (destAddress: string) => void; } const api = new Api(); -export const HarPage: React.FC = ({setAnalyzeStatus, onTLSDetected}) => { +export const TrafficPage: React.FC = ({setAnalyzeStatus, onTLSDetected}) => { const classes = useLayoutStyles(); const [entries, setEntries] = useState([] as any); const [focusedEntryId, setFocusedEntryId] = useState(null); - const [selectedHarEntry, setSelectedHarEntry] = useState(null); + const [selectedEntryData, setSelectedEntryData] = useState(null); const [connection, setConnection] = useState(ConnectionStatus.Closed); const [noMoreDataTop, setNoMoreDataTop] = useState(false); const [noMoreDataBottom, setNoMoreDataBottom] = useState(false); @@ -129,11 +129,11 @@ export const HarPage: React.FC = ({setAnalyzeStatus, onTLSDetected useEffect(() => { if (!focusedEntryId) return; - setSelectedHarEntry(null); + setSelectedEntryData(null); (async () => { try { const entryData = await api.getEntry(focusedEntryId); - setSelectedHarEntry(entryData); + setSelectedEntryData(entryData); } catch (error) { console.error(error); } @@ -170,16 +170,16 @@ export const HarPage: React.FC = ({setAnalyzeStatus, onTLSDetected const onScrollEvent = (isAtBottom) => { isAtBottom ? setDisableScrollList(false) : setDisableScrollList(true) } - + const isScrollable = (element) => { - return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientHeight; + return element.scrollHeight > element.clientHeight; }; return ( -
-
+
+
pause + src={connection === ConnectionStatus.Connected ? pauseIcon : playIcon} onClick={toggleConnection}/>
{getConnectionTitle()}
@@ -187,9 +187,9 @@ export const HarPage: React.FC = ({setAnalyzeStatus, onTLSDetected
- {entries.length > 0 &&
-
- 0 &&
+
+ = ({setAnalyzeStatus, onTLSDetected setPathFilter={setPathFilter} />
- = ({setAnalyzeStatus, onTLSDetected
- {selectedHarEntry && - } + {selectedEntryData && }
} {tappingStatus?.pods != null && } diff --git a/ui/src/components/Checkbox.tsx b/ui/src/components/UI/Checkbox.tsx similarity index 100% rename from ui/src/components/Checkbox.tsx rename to ui/src/components/UI/Checkbox.tsx diff --git a/ui/src/components/CollapsibleContainer.tsx b/ui/src/components/UI/CollapsibleContainer.tsx similarity index 95% rename from ui/src/components/CollapsibleContainer.tsx rename to ui/src/components/UI/CollapsibleContainer.tsx index aad6b1552..4c0452623 100644 --- a/ui/src/components/CollapsibleContainer.tsx +++ b/ui/src/components/UI/CollapsibleContainer.tsx @@ -1,6 +1,6 @@ import React, {useState} from "react"; -import collapsedImg from "./assets/collapsed.svg"; -import expandedImg from "./assets/expanded.svg"; +import collapsedImg from "../assets/collapsed.svg"; +import expandedImg from "../assets/expanded.svg"; import "./style/CollapsibleContainer.sass"; interface Props { diff --git a/ui/src/components/EndpointPath.tsx b/ui/src/components/UI/EndpointPath.tsx similarity index 100% rename from ui/src/components/EndpointPath.tsx rename to ui/src/components/UI/EndpointPath.tsx diff --git a/ui/src/components/FancyTextDisplay.tsx b/ui/src/components/UI/FancyTextDisplay.tsx similarity index 97% rename from ui/src/components/FancyTextDisplay.tsx rename to ui/src/components/UI/FancyTextDisplay.tsx index c61a85bd5..91f10f4bf 100644 --- a/ui/src/components/FancyTextDisplay.tsx +++ b/ui/src/components/UI/FancyTextDisplay.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useState } from 'react'; import { CopyToClipboard } from 'react-copy-to-clipboard'; -import duplicateImg from "./assets/duplicate.svg"; +import duplicateImg from "../assets/duplicate.svg"; import './style/FancyTextDisplay.sass'; interface Props { diff --git a/ui/src/components/HARFilterSelect.tsx b/ui/src/components/UI/FilterSelect.tsx similarity index 69% rename from ui/src/components/HARFilterSelect.tsx rename to ui/src/components/UI/FilterSelect.tsx index c4bc51804..bf6764ad0 100644 --- a/ui/src/components/HARFilterSelect.tsx +++ b/ui/src/components/UI/FilterSelect.tsx @@ -1,9 +1,9 @@ import React from "react"; import { MenuItem } from '@material-ui/core'; -import style from './style/HARFilterSelect.module.sass'; +import style from './style/FilterSelect.module.sass'; import { Select, SelectProps } from "./Select"; -interface HARFilterSelectProps extends SelectProps { +interface FilterSelectProps extends SelectProps { items: string[]; value: string | string[]; onChange: (string) => void; @@ -12,7 +12,7 @@ interface HARFilterSelectProps extends SelectProps { transformDisplay?: (string) => string; } -export const HARFilterSelect: React.FC = ({items, value, onChange, label, allowMultiple= false, transformDisplay}) => { +export const FilterSelect: React.FC = ({items, value, onChange, label, allowMultiple= false, transformDisplay}) => { return