Skip to content
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

[Security Solution] Coverage overview rule duplication fix #169708

Merged
merged 9 commits into from
Nov 6, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ export async function buildCoverageOverviewDashboardModel(

for (const technique of tactic.techniques) {
for (const ruleId of apiResponse.coverage[technique.id] ?? []) {
addRule(technique, ruleId, apiResponse.rules_data[ruleId]);
if (apiResponse.coverage[tactic.id] && apiResponse.coverage[tactic.id].includes(ruleId)) {
dplumlee marked this conversation as resolved.
Show resolved Hide resolved
addRule(technique, ruleId, apiResponse.rules_data[ruleId]);
}
}

for (const subtechnique of technique.subtechniques) {
for (const ruleId of apiResponse.coverage[subtechnique.id] ?? []) {
addRule(subtechnique, ruleId, apiResponse.rules_data[ruleId]);
if (
apiResponse.coverage[tactic.id] &&
apiResponse.coverage[technique.id] &&
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you missed adding apiResponse.coverage[technique.id]?.includes(ruleId) condition here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this is necessary due to techniques -> subtechniques having a one to many relationship as denoted by their id (eg. T001.001). Having the delineation based on the tactic should cover all our use cases

apiResponse.coverage[tactic.id].includes(ruleId)
) {
addRule(subtechnique, ruleId, apiResponse.rules_data[ruleId]);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ export function buildCoverageOverviewMitreGraph(
const tacticToTechniquesMap = new Map<string, CoverageOverviewMitreTechnique[]>(); // Map(kebabCase(tactic name) -> CoverageOverviewMitreTechnique)

for (const technique of techniques) {
const coverageOverviewMitreTechnique: CoverageOverviewMitreTechnique = {
id: technique.id,
name: technique.name,
reference: technique.reference,
subtechniques: techniqueToSubtechniquesMap.get(technique.id) ?? [],
enabledRules: [],
disabledRules: [],
availableRules: [],
};
const relatedSubtechniques = techniqueToSubtechniquesMap.get(technique.id) ?? [];

for (const kebabCaseTacticName of technique.tactics) {
const coverageOverviewMitreTechnique: CoverageOverviewMitreTechnique = {
id: technique.id,
name: technique.name,
reference: technique.reference,
subtechniques: relatedSubtechniques,
enabledRules: [],
disabledRules: [],
availableRules: [],
};
const tacticTechniques = tacticToTechniquesMap.get(kebabCaseTacticName);

if (!tacticTechniques) {
Expand Down