mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-10 21:02:21 +00:00
Remove TLSWarning
React component (#1014)
This commit is contained in:
parent
c5006e5f57
commit
189c158150
@ -4,18 +4,13 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/patrickmn/go-cache"
|
|
||||||
"github.com/up9inc/mizu/agent/pkg/models"
|
"github.com/up9inc/mizu/agent/pkg/models"
|
||||||
"github.com/up9inc/mizu/shared"
|
"github.com/up9inc/mizu/shared"
|
||||||
)
|
)
|
||||||
|
|
||||||
const tlsLinkRetainmentTime = time.Minute * 15
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
authStatus *models.AuthStatus
|
authStatus *models.AuthStatus
|
||||||
RecentTLSLinks = cache.New(tlsLinkRetainmentTime, tlsLinkRetainmentTime)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAuthStatus() (*models.AuthStatus, error) {
|
func GetAuthStatus() (*models.AuthStatus, error) {
|
||||||
|
@ -54,11 +54,6 @@ export default class Api {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecentTLSLinks = async () => {
|
|
||||||
const response = await client.get("/status/recentTLSLinks");
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
getOasServices = async () => {
|
getOasServices = async () => {
|
||||||
const response = await client.get("/oas");
|
const response = await client.get("/oas");
|
||||||
return response.data;
|
return response.data;
|
||||||
@ -121,4 +116,4 @@ export function getWebsocketUrl(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return websocketUrl;
|
return websocketUrl;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
.httpsDomains
|
|
||||||
display: none
|
|
||||||
margin: 0
|
|
||||||
padding: 0
|
|
||||||
list-style: none
|
|
||||||
|
|
||||||
.customWarningStyle
|
|
||||||
&:hover
|
|
||||||
overflow-y: scroll
|
|
||||||
height: 85px
|
|
||||||
.httpsDomains
|
|
||||||
display: block
|
|
@ -1,44 +0,0 @@
|
|||||||
import {Snackbar} from "@material-ui/core";
|
|
||||||
import MuiAlert from "@material-ui/lab/Alert";
|
|
||||||
import React, {useEffect} from "react";
|
|
||||||
import { RecoilState, useRecoilValue } from "recoil";
|
|
||||||
import TrafficViewerApiAtom from "../../recoil/TrafficViewerApi/atom";
|
|
||||||
import TrafficViewerApi from "../TrafficViewer/TrafficViewerApi";
|
|
||||||
import './TLSWarning.sass';
|
|
||||||
|
|
||||||
interface TLSWarningProps {
|
|
||||||
showTLSWarning: boolean
|
|
||||||
setShowTLSWarning: (show: boolean) => void
|
|
||||||
addressesWithTLS: Set<string>
|
|
||||||
setAddressesWithTLS: (addresses: Set<string>) => void
|
|
||||||
userDismissedTLSWarning: boolean
|
|
||||||
setUserDismissedTLSWarning: (flag: boolean) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export const TLSWarning: React.FC<TLSWarningProps> = ({showTLSWarning, setShowTLSWarning, addressesWithTLS, setAddressesWithTLS, userDismissedTLSWarning, setUserDismissedTLSWarning}) => {
|
|
||||||
|
|
||||||
const trafficViewerApi = useRecoilValue(TrafficViewerApiAtom as RecoilState<TrafficViewerApi>)
|
|
||||||
useEffect(() => {
|
|
||||||
(async () => {
|
|
||||||
try {
|
|
||||||
const getRecentTLSLinksFunc = trafficViewerApi?.getRecentTLSLinks ? trafficViewerApi?.getRecentTLSLinks : function(){}
|
|
||||||
const recentTLSLinks = await getRecentTLSLinksFunc();
|
|
||||||
if (recentTLSLinks?.length > 0) {
|
|
||||||
setAddressesWithTLS(new Set(recentTLSLinks));
|
|
||||||
setShowTLSWarning(true);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
}, [setShowTLSWarning, setAddressesWithTLS,trafficViewerApi]);
|
|
||||||
|
|
||||||
return (<Snackbar open={showTLSWarning && !userDismissedTLSWarning}>
|
|
||||||
<MuiAlert classes={{filledWarning: 'customWarningStyle'}} elevation={6} variant="filled"
|
|
||||||
onClose={() => setUserDismissedTLSWarning(true)} severity="warning">
|
|
||||||
Mizu is detecting TLS traffic, this type of traffic will not be displayed.
|
|
||||||
{addressesWithTLS.size > 0 &&
|
|
||||||
<ul className="httpsDomains"> {Array.from(addressesWithTLS, address => <li>{address}</li>)} </ul>}
|
|
||||||
</MuiAlert>
|
|
||||||
</Snackbar>);
|
|
||||||
}
|
|
@ -14,7 +14,6 @@ import {RecoilRoot, RecoilState, useRecoilState, useRecoilValue, useSetRecoilSta
|
|||||||
import entriesAtom from "../../recoil/entries";
|
import entriesAtom from "../../recoil/entries";
|
||||||
import focusedEntryIdAtom from "../../recoil/focusedEntryId";
|
import focusedEntryIdAtom from "../../recoil/focusedEntryId";
|
||||||
import queryAtom from "../../recoil/query";
|
import queryAtom from "../../recoil/query";
|
||||||
import {TLSWarning} from "../TLSWarning/TLSWarning";
|
|
||||||
import trafficViewerApiAtom from "../../recoil/TrafficViewerApi"
|
import trafficViewerApiAtom from "../../recoil/TrafficViewerApi"
|
||||||
import TrafficViewerApi from "./TrafficViewerApi";
|
import TrafficViewerApi from "./TrafficViewerApi";
|
||||||
import {StatusBar} from "../UI/StatusBar";
|
import {StatusBar} from "../UI/StatusBar";
|
||||||
@ -77,10 +76,6 @@ export const TrafficViewer: React.FC<TrafficViewerProps> = ({
|
|||||||
const setLeftOffTop = useSetRecoilState(leftOffTopAtom);
|
const setLeftOffTop = useSetRecoilState(leftOffTopAtom);
|
||||||
const scrollableRef = useRef(null);
|
const scrollableRef = useRef(null);
|
||||||
|
|
||||||
const [showTLSWarning, setShowTLSWarning] = useState(false);
|
|
||||||
const [userDismissedTLSWarning, setUserDismissedTLSWarning] = useState(false);
|
|
||||||
const [addressesWithTLS, setAddressesWithTLS] = useState(new Set<string>());
|
|
||||||
|
|
||||||
const handleQueryChange = useMemo(
|
const handleQueryChange = useMemo(
|
||||||
() =>
|
() =>
|
||||||
debounce(async (query: string) => {
|
debounce(async (query: string) => {
|
||||||
@ -286,12 +281,6 @@ export const TrafficViewer: React.FC<TrafficViewerProps> = ({
|
|||||||
<EntryDetailed/>
|
<EntryDetailed/>
|
||||||
</div>
|
</div>
|
||||||
</div>}
|
</div>}
|
||||||
<TLSWarning showTLSWarning={showTLSWarning}
|
|
||||||
setShowTLSWarning={setShowTLSWarning}
|
|
||||||
addressesWithTLS={addressesWithTLS}
|
|
||||||
setAddressesWithTLS={setAddressesWithTLS}
|
|
||||||
userDismissedTLSWarning={userDismissedTLSWarning}
|
|
||||||
setUserDismissedTLSWarning={setUserDismissedTLSWarning}/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,6 @@ type TrafficViewerApi = {
|
|||||||
analyzeStatus: () => any
|
analyzeStatus: () => any
|
||||||
fetchEntries: (leftOff: any, direction: number, query: any, limit: number, timeoutMs: number) => any
|
fetchEntries: (leftOff: any, direction: number, query: any, limit: number, timeoutMs: number) => any
|
||||||
getEntry: (entryId: any, query: string) => any
|
getEntry: (entryId: any, query: string) => any
|
||||||
getRecentTLSLinks: () => any,
|
|
||||||
webSocket: {
|
webSocket: {
|
||||||
close: () => void
|
close: () => void
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,6 @@ export default class Api {
|
|||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecentTLSLinks = async () => {
|
|
||||||
const response = await client.get("/status/recentTLSLinks");
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
getAuthStatus = async () => {
|
getAuthStatus = async () => {
|
||||||
const response = await client.get("/status/auth");
|
const response = await client.get("/status/auth");
|
||||||
return response.data;
|
return response.data;
|
||||||
|
Loading…
Reference in New Issue
Block a user