Merge remote-tracking branch 'origin/GP-0_Dan_schemaVisibility' into patch

This commit is contained in:
Ryan Kurtz 2023-08-09 13:15:59 -04:00
commit e557e40f99
2 changed files with 33 additions and 1 deletions

View File

@ -907,7 +907,9 @@ public interface TargetObjectSchema {
return false;
}
AttributeSchema schema = getAttributeSchema(key);
if (schema == AttributeSchema.DEFAULT_ANY || schema == AttributeSchema.DEFAULT_OBJECT) {
if (schema == AttributeSchema.DEFAULT_ANY ||
schema == AttributeSchema.DEFAULT_OBJECT ||
schema == AttributeSchema.DEFAULT_VOID) {
// FIXME: Remove this hack once we stop depending on this prefix
return key.startsWith(TargetObject.PREFIX_INVISIBLE);
}

View File

@ -46,6 +46,7 @@ public class DBTraceObjectManagerTest extends AbstractGhidraHeadlessIntegrationT
<schema name='Session' elementResync='NEVER' attributeResync='ONCE'>
<attribute name='curTarget' schema='Target' />
<attribute name='Targets' schema='TargetContainer' />
<attribute schema='VOID' />
</schema>
<schema name='TargetContainer' canonical='yes' elementResync='NEVER'
attributeResync='ONCE'>
@ -1063,4 +1064,33 @@ public class DBTraceObjectManagerTest extends AbstractGhidraHeadlessIntegrationT
assertFalse(split.isDeleted()); // Other values not affected
}
}
@Test
public void testAttributeDefaultVisibility() {
try (Transaction tx = b.startTransaction()) {
TraceObjectValue rootVal =
manager.createRootObject(ctx.getSchema(new SchemaName("Session")));
root = rootVal.getChild();
TraceObject object = manager.createObject(TraceObjectKeyPath.parse("OutsideSchema"));
object.insert(Lifespan.ALL, ConflictResolution.DENY);
assertFalse(object.getCanonicalParent(0).isHidden());
TraceObject elemOutside =
manager.createObject(TraceObjectKeyPath.parse("OutsideSchema[0]"));
elemOutside.insert(Lifespan.ALL, ConflictResolution.DENY);
assertFalse(elemOutside.getCanonicalParent(0).isHidden());
TraceObject attrOutside =
manager.createObject(TraceObjectKeyPath.parse("OutsideSchema.Attr"));
attrOutside.insert(Lifespan.ALL, ConflictResolution.DENY);
assertFalse(attrOutside.getCanonicalParent(0).isHidden());
// TODO: This underscore convention is deprecated, but still in use
TraceObject hiddenOutside =
manager.createObject(TraceObjectKeyPath.parse("OutsideSchema._Attr"));
hiddenOutside.insert(Lifespan.ALL, ConflictResolution.DENY);
assertTrue(hiddenOutside.getCanonicalParent(0).isHidden());
}
}
}