mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 09:49:23 +02:00
Merge remote-tracking branch 'origin/GP-5749_ghidra1_SARIF_improvements' into Ghidra_11.4
This commit is contained in:
commit
4a65e9af3b
2 changed files with 53 additions and 47 deletions
|
@ -77,10 +77,11 @@ public class SarifClassesNamespaceWriter extends AbstractExtWriter {
|
|||
objects.add(getTree(sarif));
|
||||
|
||||
SymbolIterator symbols = symbolTable.getSymbols(cls);
|
||||
if (cls.isExternal()) {
|
||||
while (symbols.hasNext()) {
|
||||
Symbol sym = symbols.next();
|
||||
if (cls.isExternal()) {
|
||||
ExternalLocation loc = externalManager.getExternalLocation(sym);
|
||||
if (loc != null) {
|
||||
ExtLibraryLocation obj = new ExtLibraryLocation(loc);
|
||||
SarifObject sarif2 = new SarifObject(ExternalLibSarifMgr.SUBKEY1, ExternalLibSarifMgr.KEY, getTree(obj),
|
||||
loc.getAddress(), loc.getAddress());
|
||||
|
@ -88,6 +89,7 @@ public class SarifClassesNamespaceWriter extends AbstractExtWriter {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public JsonArray getResults() {
|
||||
return objects;
|
||||
|
|
|
@ -54,22 +54,10 @@ public class FunctionsSarifMgr extends SarifMgr {
|
|||
FID_BOOKMARK_CATEGORY);
|
||||
|
||||
private DtParser dtParser;
|
||||
private Library extenalNamespace;
|
||||
private Library externalNamespace;
|
||||
|
||||
FunctionsSarifMgr(Program program, MessageLog log) {
|
||||
super(KEY, program, log);
|
||||
int txId = program.startTransaction("SARIF FunctionMgr");
|
||||
try {
|
||||
SymbolTable symbolTable = program.getSymbolTable();
|
||||
Symbol extLib = symbolTable.getLibrarySymbol("<EXTERNAL>");
|
||||
if (extLib == null) {
|
||||
extenalNamespace = symbolTable.createExternalLibrary(Library.UNKNOWN, SourceType.IMPORTED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.appendException(e);
|
||||
} finally {
|
||||
program.endTransaction(txId, true);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
|
@ -233,6 +221,24 @@ public class FunctionsSarifMgr extends SarifMgr {
|
|||
return func;
|
||||
}
|
||||
|
||||
private Library getExternalNamespace(Program program, MessageLog log) {
|
||||
if (externalNamespace == null) {
|
||||
int txId = program.startTransaction("SARIF FunctionMgr");
|
||||
try {
|
||||
SymbolTable symbolTable = program.getSymbolTable();
|
||||
Symbol extLib = symbolTable.getLibrarySymbol("<EXTERNAL>");
|
||||
if (extLib == null) {
|
||||
externalNamespace = symbolTable.createExternalLibrary(Library.UNKNOWN, SourceType.IMPORTED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.appendException(e);
|
||||
} finally {
|
||||
program.endTransaction(txId, true);
|
||||
}
|
||||
}
|
||||
return externalNamespace;
|
||||
}
|
||||
|
||||
private void setName(Address entryPoint, Function func, String name, Map<String, Object> result) {
|
||||
SymbolPath path = new SymbolPath(name);
|
||||
if (name != null) {
|
||||
|
@ -248,7 +254,6 @@ public class FunctionsSarifMgr extends SarifMgr {
|
|||
}
|
||||
|
||||
Symbol symbol = func.getSymbol();
|
||||
if (path != null) {
|
||||
try {
|
||||
Namespace ns = NamespaceUtils.getFunctionNamespaceAt(program, path, entryPoint);
|
||||
if (ns == null) {
|
||||
|
@ -264,8 +269,8 @@ public class FunctionsSarifMgr extends SarifMgr {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if (path != null && path.getName().contains(Library.UNKNOWN)) {
|
||||
ns = extenalNamespace;
|
||||
if (path.getName().contains(Library.UNKNOWN)) {
|
||||
ns = getExternalNamespace(program, log);
|
||||
}
|
||||
if (ns.getParentNamespace() == null) {
|
||||
symbol.setName(name, getSourceType("DEFAULT"));
|
||||
|
@ -276,7 +281,6 @@ public class FunctionsSarifMgr extends SarifMgr {
|
|||
// name may already be set if symbols were loaded...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String setProperties(Map<String, Object> result, Function func, Address entryPoint)
|
||||
throws InvalidInputException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue