From dfd6d543074b4a30c2fc990063ca69ebf8a734e1 Mon Sep 17 00:00:00 2001 From: Emiliano Ciavatta Date: Wed, 16 Sep 2020 17:49:50 +0200 Subject: Fix body decoding bugs. Improve frontend --- frontend/src/components/ConnectionContent.js | 82 +++++++++++++++++++--------- 1 file changed, 55 insertions(+), 27 deletions(-) (limited to 'frontend/src/components/ConnectionContent.js') diff --git a/frontend/src/components/ConnectionContent.js b/frontend/src/components/ConnectionContent.js index 51dbb67..20ec92b 100644 --- a/frontend/src/components/ConnectionContent.js +++ b/frontend/src/components/ConnectionContent.js @@ -2,7 +2,6 @@ import React, {Component} from 'react'; import './ConnectionContent.scss'; import {Button, Dropdown, Row} from 'react-bootstrap'; import axios from 'axios'; -import {timestampToDateTime, timestampToTime} from "../utils"; import MessageAction from "./MessageAction"; const classNames = require('classnames'); @@ -15,7 +14,7 @@ class ConnectionContent extends Component { loading: false, connectionContent: null, format: "default", - decoded: false, + tryParse: true, messageActionDialog: null }; @@ -43,16 +42,12 @@ class ConnectionContent extends Component { } } - toggleDecoded() { - this.setState({decoded: !this.state.decoded}); - } - tryParseConnectionMessage(connectionMessage) { if (connectionMessage.metadata == null) { return connectionMessage.content; } if (connectionMessage["is_metadata_continuation"]) { - return already parsed in previous messages; + return **already parsed in previous messages**; } let unrollMap = (obj) => obj == null ? null : Object.entries(obj).map(([key, value]) => @@ -62,16 +57,17 @@ class ConnectionContent extends Component { let m = connectionMessage.metadata; switch (m.type) { case "http-request": - let url = {m.host}{m.url}; + let url = {m.host}{m.url}; return -

{m.method} {url} {m.protocol}

+

{m.method} {url} {m.protocol}

{unrollMap(m.headers)}
{m.body}
{unrollMap(m.trailers)}
; case "http-response": return -

{m.protocol} {m.status}

+

{m.protocol} {m.status}

{unrollMap(m.headers)}
{m.body}
{unrollMap(m.trailers)} @@ -87,9 +83,10 @@ class ConnectionContent extends Component { } return Object.entries(connectionMessage.metadata["reproducers"]).map(([actionName, actionValue]) => - ); @@ -115,8 +112,9 @@ class ConnectionContent extends Component {
{c.from_client ? "client" : "server"}
-
- {this.state.decoded ? this.tryParseConnectionMessage(c) : c.content} +
+ {this.state.tryParse && this.state.format === "default" ? this.tryParseConnectionMessage(c) : c.content}
); @@ -129,25 +127,55 @@ class ConnectionContent extends Component { flow: {this.props.connection.ip_src}:{this.props.connection.port_src} -> {this.props.connection.ip_dst}:{this.props.connection.port_dst} | timestamp: {this.props.connection.started_at} -
- - +
+ + format - plain - hex - hexdump - base32 - base64 - ascii - binary - decimal - octal + plain + hex + hexdump + base32 + base64 + ascii + binary + decimal + octal + + + + + + view_as + + + + default - + + + + + download_as + + + + nl_separated + only_client + only_server +
-- cgit v1.2.3-70-g09d2