New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/change tactis and techniques resources #3346
Merged
eze9252
merged 24 commits into
feature/3291-mitre-attack-intelligence-section
from
feature/change-tactis-and-techniques-resources
Jun 15, 2021
Merged
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7ea3633
change endpoint and adapt component in mitre
eze9252 d809f34
fix flyout
eze9252 75774a1
add redirect to intelligence
eze9252 b63b4d5
fix merge
eze9252 aad3eaa
fix merge flyout
eze9252 5adeba6
fix package version
eze9252 dc6c792
fix PR comments and add intelligence section redirect
eze9252 38a5d62
Created new Mitre flyout
CPAlejandro 57cb78f
Changelog
CPAlejandro acec181
fix comments PR
Desvelao 80fcf26
add redirect values in query params
eze9252 8c2f505
apply prettier
eze9252 4546afc
Resolving comments and upgrading code
CPAlejandro a3f5b42
Applying comments upgrades to references table
CPAlejandro c47e246
Applying more upgrade comments
CPAlejandro e217c98
fix(mitre_intelligence): Remove the Promise.reject in resource detail…
Desvelao 8ad0be8
clear comments and imports
eze9252 1a0c446
fix error handler techniques
eze9252 f9f37fe
delete session storage
eze9252 57381b3
delete files and fix get techniques data
eze9252 9a53d05
fix redirect flyout to rules
eze9252 34b01ff
Merge branch 'feature/3291-mitre-attack-intelligence-section' into fe…
eze9252 b030b2b
fix comments PR
eze9252 f919a27
Merge branch 'feature/change-tactis-and-techniques-resources' of http…
eze9252 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ export class FlyoutTechnique extends Component { | |
props!: { | ||
currentTechniqueData: any | ||
currentTechnique: string | ||
tacticsObject: any | ||
} | ||
|
||
filterManager: FilterManager; | ||
|
@@ -118,9 +119,9 @@ export class FlyoutTechnique extends Component { | |
try{ | ||
this.setState({loading: true, techniqueData: {}}); | ||
const { currentTechnique } = this.props; | ||
const result = await WzRequest.apiReq('GET', '/mitre', { | ||
const result = await WzRequest.apiReq('GET', '/mitre/techniques', { | ||
params: { | ||
q: `id=${currentTechnique}` | ||
q: `references.external_id=${currentTechnique}` | ||
} | ||
}); | ||
const rawData = (((result || {}).data || {}).data || {}).affected_items | ||
|
@@ -130,36 +131,20 @@ export class FlyoutTechnique extends Component { | |
} | ||
} | ||
|
||
formatTechniqueData (rawData) { | ||
const { platform_name, phase_name} = rawData; | ||
const { name, description, x_mitre_version: version, x_mitre_data_sources, external_references } = rawData.json; | ||
|
||
const replaced_external_references = []; | ||
let index_replaced_external_references = 0; | ||
let last_citation_string = ''; | ||
const descriptionWithCitations = external_references.reduce((accum, reference) => { | ||
return accum | ||
.replace(new RegExp(`\\(Citation: ${reference.source_name}\\)`,'g'), (token) => { | ||
if(last_citation_string !== token){ | ||
index_replaced_external_references++; | ||
replaced_external_references.push({...reference, index: index_replaced_external_references}); | ||
last_citation_string = token; | ||
} | ||
return `<a style="vertical-align: super;" rel="noreferrer" class="euiLink euiLink--primary technique-reference-citation-${index_replaced_external_references}">[${String(index_replaced_external_references)}]</a>`; | ||
}) | ||
}, description); | ||
this.setState({techniqueData: { name, description: descriptionWithCitations, phase_name, platform_name, version, x_mitre_data_sources, external_references, replaced_external_references }, loading: false }) | ||
findTacticName(tactics){ | ||
const { tacticsObject } = this.props; | ||
const getTactic = (element) => { | ||
const tactic = Object.values(tacticsObject).find(obj => obj.id === element); | ||
return { id:tactic.references[0].external_id, name: tactic.name}; | ||
}; | ||
return tactics.reduce((tacticsObj, element) => [...tacticsObj, getTactic(element)], []); | ||
} | ||
|
||
getArrayFormatted(arrayText) { | ||
try { | ||
const stringText = arrayText.toString(); | ||
const splitString = stringText.split(','); | ||
const resultString = splitString.join(', '); | ||
return resultString; | ||
} catch (err) { | ||
return arrayText; | ||
} | ||
formatTechniqueData (rawData) { | ||
const { tactics, name, mitre_version } = rawData; | ||
const tacticsObj = this.findTacticName(tactics) | ||
|
||
this.setState({techniqueData: { name, mitre_version, tacticsObj }, loading: false }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Semicolon |
||
} | ||
|
||
renderHeader() { | ||
|
@@ -180,7 +165,7 @@ export class FlyoutTechnique extends Component { | |
</EuiFlyoutHeader> | ||
) | ||
} | ||
|
||
renderBody() { | ||
const { currentTechnique } = this.props; | ||
const { techniqueData } = this.state; | ||
|
@@ -204,60 +189,45 @@ export class FlyoutTechnique extends Component { | |
title: 'ID', | ||
description: ( <EuiToolTip | ||
position="top" | ||
content={"Open " + currentTechnique + " details in a new page"}> | ||
<EuiLink href={link} external target="_blank"> | ||
content={"Open " + currentTechnique + " details in Intelligence section"}> | ||
<EuiLink onClick={(e) => {this.props.openIntelligence(e,'techniques',currentTechnique);e.stopPropagation()}}> | ||
{currentTechnique} | ||
</EuiLink> | ||
</EuiToolTip>) | ||
}, | ||
{ | ||
title: 'Tactic', | ||
description: this.getArrayFormatted( | ||
techniqueData.phase_name | ||
) | ||
}, | ||
{ | ||
title: 'Platform', | ||
description: this.getArrayFormatted( | ||
techniqueData.platform_name | ||
) | ||
}, | ||
{ | ||
title: 'Data sources', | ||
description: this.getArrayFormatted( | ||
techniqueData.x_mitre_data_sources | ||
) | ||
title: 'Tactics', | ||
description: techniqueData.tacticsObj | ||
? techniqueData.tacticsObj.map((tactic) => { | ||
return ( | ||
<> | ||
<EuiToolTip | ||
position="top" | ||
content={ | ||
"Open " + tactic.name + " details in a Intelligence section" | ||
} | ||
> | ||
<EuiLink | ||
onClick={(e) => { | ||
this.props.openIntelligence(e, "tactics", tactic.id); | ||
e.stopPropagation(); | ||
}} | ||
> | ||
{tactic.name} | ||
</EuiLink> | ||
</EuiToolTip> | ||
<br /> | ||
</> | ||
); | ||
}) | ||
: "" | ||
}, | ||
{ | ||
title: 'Version', | ||
description: techniqueData.version | ||
}, | ||
{ | ||
title: 'Description', | ||
description: formattedDescription | ||
}, | ||
description: techniqueData.mitre_version | ||
} | ||
|
||
]; | ||
if(techniqueData && techniqueData.replaced_external_references && techniqueData.replaced_external_references.length > 0){ | ||
data.push({ | ||
title: 'References', | ||
description: ( | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
{techniqueData.replaced_external_references.map((external_reference, external_reference_index) => ( | ||
<div key={`external_reference-${external_reference.index}`} id={`technique-reference-${external_reference.index}`}> | ||
<span>{external_reference.index}. </span> | ||
<EuiLink href={external_reference.url} target='_blank'> | ||
{external_reference.source_name} | ||
</EuiLink> | ||
</div> | ||
) | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
) | ||
}) | ||
} | ||
return ( | ||
<EuiFlyoutBody className="flyout-body" > | ||
<EuiAccordion | ||
|
@@ -279,13 +249,6 @@ export class FlyoutTechnique extends Component { | |
)) || ( | ||
<div style={{marginBottom: 30}}> | ||
<EuiDescriptionList listItems={data} /> | ||
<EuiSpacer /> | ||
<p> | ||
More info:{' '} | ||
<EuiLink href={link} target="_blank"> | ||
{`MITRE ATT&CK - ${currentTechnique}`} | ||
</EuiLink> | ||
</p> | ||
</div> | ||
)} | ||
</div> | ||
|
@@ -320,7 +283,7 @@ export class FlyoutTechnique extends Component { | |
initialIsOpen={true}> | ||
<EuiFlexGroup className="flyout-row"> | ||
<EuiFlexItem> | ||
<Discover kbnSearchBar shareFilterManager={this.filterManager} initialColumns={["icon", "timestamp", 'rule.mitre.id', 'rule.mitre.tactic', 'rule.level', 'rule.id', 'rule.description']} implicitFilters={implicitFilters} initialFilters={[]} updateTotalHits={(total) => this.updateTotalHits(total)}/> | ||
<Discover kbnSearchBar shareFilterManager={this.filterManager} initialColumns={["icon", "timestamp", 'rule.mitre.id', 'rule.mitre.tactic', 'rule.level', 'rule.id', 'rule.description']} implicitFilters={implicitFilters} initialFilters={[]} updateTotalHits={(total) => this.updateTotalHits(total)} openIntelligence={(e,redirectTo,itemId) => this.props.openIntelligence(e,redirectTo,itemId)}/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiAccordion> | ||
|
11 changes: 0 additions & 11 deletions
11
.../components/overview/mitre/components/techniques/components/search-bar-tecniques/index.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...iew/mitre/components/techniques/components/search-bar-tecniques/search-bar-techniques.tsx
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
public/components/overview/mitre/components/techniques/components/technique/index.ts
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
public/components/overview/mitre/components/techniques/components/technique/teqnique.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use
.map
instead of.reduce
here.