Skip to content

Conversation

shreyamalviya
Copy link
Contributor

@shreyamalviya shreyamalviya commented Nov 7, 2022

What does this PR do?

Fixes #2507

PR Checklist

  • Have you added an explanation of what your changes do and why you'd like to include them?
  • Is the TravisCI build passing?
  • Was the CHANGELOG.md updated to reflect the changes?
  • Was the documentation framework updated to reflect the changes?
  • Have you checked that you haven't introduced any duplicate code?

Testing Checklist

  • Added relevant unit tests?
  • Have you successfully tested your changes locally? Elaborate:

    Tested by running the Island and checking the report with dummy data

  • If applicable, add screenshots or log transcripts of the feature working

image

@shreyamalviya shreyamalviya force-pushed the 2507-tunnel-issue-in-ui branch from 52c120c to ca0fb5c Compare November 8, 2022 06:45
@shreyamalviya
Copy link
Contributor Author

Updated screenshot:
image

@shreyamalviya shreyamalviya marked this pull request as ready for review November 8, 2022 08:50
Copy link
Contributor

@ilija-lazoroski ilija-lazoroski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -526,6 +537,45 @@ class ReportPageComponent extends AuthComponent {
return <ul>{issuesDivArray}</ul>;
};

createTunnelingIssueComponent(agents, machines) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to the TunnelIssue.js?

Comment on lines 552 to 571
let tunnelingIssues = [];
for (let agent of agents) {
if (!islandIPs.includes(agent.cc_server.ip)) {
let agentMachine = getMachineByAgent(agent, machines);
if (agentMachine !== null) {
let agentMachineHostname = getMachineHostname(agentMachine)

let agentTunnelMachineHostname = agent.cc_server.ip;
let agentTunnelMachine = getMachineFromIP(agent.cc_server.ip, machines)
if (agentTunnelMachine !== null) {
agentTunnelMachineHostname = getMachineHostname(agentTunnelMachine);
}

tunnelingIssues.push({
'agent_machine': agentMachineHostname,
'agent_tunnel': agentTunnelMachineHostname
});
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic looks like it belongs in the tunnelIssueReport.js component

@@ -356,6 +361,11 @@ class ReportPageComponent extends AuthComponent {
overviews.push(this.getIssueOverview(this.IssueDescriptorEnum[issues[i]]));
}
}

if (this.tunnelingIssueExists === true) {
overviews.push(this.getIssueOverview(this.IssueDescriptorEnum['tunnel']))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always push the tunneling issue overview. The overview will return <></> if no tunneling happened

@@ -444,6 +454,7 @@ class ReportPageComponent extends AuthComponent {
<h3>Machine related recommendations</h3> : null}
<div>
{this.generateIssues(this.state.report.recommendations.issues)}
{this.tunnelingIssueComponent}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to store this in the state. We can just call tunnelIssueReport component here and pass machines and agents. If there's no tunneling issue, the component can return <></>

Comment on lines 116 to 118
'tunnel': {
[this.issueContentTypes.OVERVIEW]: tunnelIssueOverview,
[this.issueContentTypes.REPORT]: tunnelIssueReport,
[this.issueContentTypes.TYPE]: this.issueTypes.WARNING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this whole thing, if we turn overview and report into standalone components, they can determine by machines and agents if they should render or not

@VakarisZ
Copy link
Contributor

VakarisZ commented Nov 8, 2022

The report is already not in a great shape. But at least it has it's own abstraction layer and we shouldn't cram the logic of specific issues into it. Tunneling overview and report components can decide, based on agents and machines, whether they should return data or an empty component.

Copy link
Contributor

@VakarisZ VakarisZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the logic to tunneling issue if possible

@mssalvatore mssalvatore merged commit 218a13e into develop Nov 8, 2022
@mssalvatore mssalvatore deleted the 2507-tunnel-issue-in-ui branch November 8, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the security report's dependency on the Monkey model
4 participants