This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from cisagov/BLDSTRIKE-450-mitre-attack-names
Add MITRE ATT&CK names
- Loading branch information
Showing
9 changed files
with
440,083 additions
and
50 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { observer } from 'mobx-react-lite'; | ||
import type { ComponentProps } from 'react'; | ||
import { mitreAttackDictionary } from './mitreAttackDictionary'; | ||
|
||
type MitreAttackItem = { | ||
name: string; | ||
id: string; | ||
url: string; | ||
}; | ||
export type MitreAttackId = keyof typeof mitreAttackDictionary; | ||
// type MitreAttackDictionary = Record<keyof typeof mitreAttackDictionary, MitreAttackItem>; | ||
|
||
type MitreAttackProps = ComponentProps<'a'> & { | ||
miterAttackId: keyof typeof mitreAttackDictionary; | ||
}; | ||
|
||
export const MitreAttack = observer<MitreAttackProps>(({ miterAttackId, ...props }) => { | ||
const { name, id, url } = mitreAttackDictionary[miterAttackId] as MitreAttackItem; | ||
return ( | ||
<a | ||
children={`${id}: ${name}`} | ||
aria-label="Mitre attack links" | ||
href={url} | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
{...props} | ||
/> | ||
); | ||
}); |
435,694 changes: 435,694 additions & 0 deletions
435,694
applications/client/src/components/Mitre/enterprise-attack.json
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './MitreAttack'; | ||
export * from './mitreAttackDictionary'; |
4,204 changes: 4,204 additions & 0 deletions
4,204
applications/client/src/components/Mitre/mitreAttackDictionary.ts
Large diffs are not rendered by default.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
applications/client/src/components/Mitre/process-enterprise-attack.js
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* Run this to generate a dataset of named MITRE ATT&CKs for use in the UI | ||
* `node ./process-enterprise-attack.js` | ||
* https://attack.mitre.org/ | ||
* https://github.com/mitre/cti | ||
*/ | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// manually update this file from https://github.com/mitre/cti/blob/master/enterprise-attack/enterprise-attack.json | ||
const enterpriseAttack = require('./enterprise-attack.json'); | ||
// we could also add the other items from ics, mobile, and pre? if they have the same format | ||
|
||
const mitreAttackDictionary = {}; | ||
|
||
enterpriseAttack.objects.forEach((object) => { | ||
const externalReference = object.external_references?.find((ref) => ref.source_name === 'mitre-attack'); | ||
|
||
// some of the externalReferences don't have a mitre-attack associated | ||
if (!externalReference) return { name: object.name }; | ||
|
||
const { external_id: id, url } = externalReference; | ||
|
||
const mitreAttack = { | ||
name: object.name, | ||
id, | ||
url, | ||
}; | ||
|
||
// Mire Attacks can have sub attacks formatted 'T0000.000' | ||
const [parentTechnique, subTechnique] = id.split('.'); | ||
|
||
if (subTechnique != null) { | ||
mitreAttack.parentTechnique = parentTechnique; | ||
|
||
// add subTechnique to parentTechnique | ||
if (mitreAttackDictionary[parentTechnique] == null) { | ||
mitreAttackDictionary[parentTechnique] = { subTechniques: [subTechnique] }; | ||
} else if (mitreAttackDictionary[parentTechnique].subTechniques == null) { | ||
mitreAttackDictionary[parentTechnique].subTechniques = [subTechnique]; | ||
} else { | ||
mitreAttackDictionary[parentTechnique].subTechniques.push(subTechnique); | ||
} | ||
} | ||
|
||
// mitreAttackDictionary[id] may have been added from the subTechnique process | ||
if (mitreAttackDictionary[id] == null) { | ||
mitreAttackDictionary[id] = mitreAttack; | ||
} else { | ||
mitreAttackDictionary[id] = { | ||
...mitreAttackDictionary[id], | ||
...mitreAttack, | ||
}; | ||
} | ||
|
||
return mitreAttack; | ||
}); | ||
|
||
const alphabeticalMitreAttackDictionary = {}; | ||
Object.keys(mitreAttackDictionary) | ||
.sort() | ||
.forEach((id) => { | ||
alphabeticalMitreAttackDictionary[id] = mitreAttackDictionary[id].subTechniques | ||
? { | ||
...mitreAttackDictionary[id], | ||
subTechniques: mitreAttackDictionary[id].subTechniques.sort(), | ||
} | ||
: mitreAttackDictionary[id]; | ||
}); | ||
|
||
console.log(`Parsed ${Object.entries(alphabeticalMitreAttackDictionary).length} MITRE ATT&CK ids`); | ||
|
||
// it helps to manually run prettier on this after its generated | ||
const mitreAttackDictionaryPathTs = path.join(__dirname, 'mitreAttackDictionary.ts'); | ||
const tsFileContents = `export const mitreAttackDictionary = ${JSON.stringify(alphabeticalMitreAttackDictionary)}`; | ||
fs.writeFile(mitreAttackDictionaryPathTs, tsFileContents, (err) => { | ||
if (err) console.error(err); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
|
||
|
||
# Download MITRE ATT&CK Framework Json | ||
|
||
https://github.com/mitre/cti/blob/master/enterprise-attack/enterprise-attack.json | ||
|
||
|
||
|
||
|
||
This data may need to be updated periodically | ||
- Visit https://mitre-attack.github.io/attack-navigator/ | ||
- Select "Create New Layer" > "Enterprise" | ||
- In the top toolbar under "Selection Controls" click "Search & MultiSelect" (the search icon 🔎) | ||
- In the right panel, under "Techniques" click "Select All." | ||
- With all techniques selected, In the top toolbar under "Layer Controls" click "Download layer as json" (the down arrow icon ⬇) | ||
- replace the `layer.json` file with the newly downloaded one. |
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