Skip to content

Commit

Permalink
add file-level rules to capabilities by function
Browse files Browse the repository at this point in the history
  • Loading branch information
fariss committed Aug 16, 2024
1 parent 854759c commit b67bd4d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion web/explorer/src/utils/rdocParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export function parseFunctionCapabilities(doc) {
// Map to store capabilities matched to each function
const matchesByFunction = new Map();

// Add a special entry for file-level matches
matchesByFunction.set("file", new Set());

// Iterate through all rules in the document
for (const [, rule] of Object.entries(doc.rules)) {
if (rule.meta.scopes.static === "function") {
Expand All @@ -133,12 +136,26 @@ export function parseFunctionCapabilities(doc) {
.add({ name: rule.meta.name, namespace: rule.meta.namespace, lib: rule.meta.lib });
}
}
} else if (rule.meta.scopes.static === "file") {
// Add file-level matches to the special 'file' entry
matchesByFunction.get("file").add({
name: rule.meta.name,
namespace: rule.meta.namespace,
lib: rule.meta.lib
});
}
// (else) Ignoring file scope rules
}

const result = [];

// Add file-level matches if there are any
if (matchesByFunction.get("file").size > 0) {
result.push({
address: "file",
capabilities: Array.from(matchesByFunction.get("file"))
});
}

// Iterate through all functions in the document
for (const f of doc.meta.analysis.feature_counts.functions) {
const addr = formatAddress(f.address);
Expand Down

0 comments on commit b67bd4d

Please sign in to comment.