Skip to content

Commit

Permalink
Update OSCAL models to 1.1.0 (#165)
Browse files Browse the repository at this point in the history
* Remove mapping features and tests for #164.

* Update submodule to OSCAL 1.1.0 models for #164.
  • Loading branch information
aj-stein-nist authored Aug 1, 2023
1 parent 8f4fe6a commit 212aea9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 82 deletions.
2 changes: 1 addition & 1 deletion oscal
Submodule oscal updated 927 files
19 changes: 0 additions & 19 deletions src/main/java/gov/nist/secauto/oscal/lib/OscalBindingContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import gov.nist.secauto.oscal.lib.model.AssessmentResults;
import gov.nist.secauto.oscal.lib.model.Catalog;
import gov.nist.secauto.oscal.lib.model.ComponentDefinition;
import gov.nist.secauto.oscal.lib.model.MappingCollection;
import gov.nist.secauto.oscal.lib.model.PlanOfActionAndMilestones;
import gov.nist.secauto.oscal.lib.model.Profile;
import gov.nist.secauto.oscal.lib.model.SystemSecurityPlan;
Expand Down Expand Up @@ -107,21 +106,6 @@ public Profile loadProfile(@NonNull File file) throws IOException {
return newBoundLoader().load(Profile.class, file);
}

@NonNull
public MappingCollection loadMapping(@NonNull URL url) throws IOException, URISyntaxException {
return newBoundLoader().load(MappingCollection.class, url);
}

@NonNull
public MappingCollection loadMapping(@NonNull Path path) throws IOException {
return newBoundLoader().load(MappingCollection.class, path);
}

@NonNull
public MappingCollection loadMapping(@NonNull File file) throws IOException {
return newBoundLoader().load(MappingCollection.class, file);
}

@NonNull
public SystemSecurityPlan loadSystemSecurityPlan(@NonNull URL url) throws IOException, URISyntaxException {
return newBoundLoader().load(SystemSecurityPlan.class, url);
Expand Down Expand Up @@ -210,9 +194,6 @@ public Class<?> getBoundClassForXmlQName(QName startElementQName) {
case "profile":
clazz = Profile.class;
break;
case "mapping-collection":
clazz = MappingCollection.class;
break;
case "system-security-plan":
clazz = SystemSecurityPlan.class;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import gov.nist.secauto.oscal.lib.model.Control;
import gov.nist.secauto.oscal.lib.model.ControlPart;
import gov.nist.secauto.oscal.lib.model.Link;
import gov.nist.secauto.oscal.lib.model.MappingEntry;
import gov.nist.secauto.oscal.lib.model.Parameter;
import gov.nist.secauto.oscal.lib.model.Property;
import gov.nist.secauto.oscal.lib.model.control.catalog.ICatalogVisitor;
Expand All @@ -60,9 +59,7 @@ public enum TargetType {
PARAM("param", Parameter.class),
PROP("prop", Property.class),
LINK("link", Link.class),
PART("part", ControlPart.class),
MAPPING("mapping", Control.Mapping.class),
MAP("map", MappingEntry.class);
PART("part", ControlPart.class);

@NonNull
private static final Map<Class<?>, TargetType> CLASS_TO_TYPE;
Expand Down Expand Up @@ -157,8 +154,6 @@ public Class<?> getClazz() {
APPLICABLE_TARGETS = new EnumMap<>(TargetType.class);
APPLICABLE_TARGETS.put(TargetType.PARAM, Set.of(TargetType.PROP, TargetType.LINK));
APPLICABLE_TARGETS.put(TargetType.PART, Set.of(TargetType.PART, TargetType.PROP, TargetType.LINK));
APPLICABLE_TARGETS.put(TargetType.MAPPING, Set.of(TargetType.MAP, TargetType.PROP, TargetType.LINK));
APPLICABLE_TARGETS.put(TargetType.MAP, Set.of(TargetType.PROP, TargetType.LINK));
}

private static Set<TargetType> getApplicableTypes(@NonNull TargetType type) {
Expand Down Expand Up @@ -276,11 +271,6 @@ public Boolean visitControl(Control control, Context context) {
child -> visitPart(child, context),
context);

// visit mappings
Control.Mapping mapping = control.getMapping();
if (mapping != null) {
retval = retval || visitMapping(mapping, context);
}
return retval;
}

Expand Down Expand Up @@ -339,54 +329,6 @@ public boolean visitPart(ControlPart part, Context context) {
return retval;
}

/**
* Visit the control mapping.
*
* @param mapping
* the bound mapping object
* @param context
* the visitor context
* @return {@code true} if the removal was applied or {@code false} otherwise
*/
public boolean visitMapping(Control.Mapping mapping, Context context) {
assert context != null;

// visit maps
return handle(
TargetType.MAP,
() -> CollectionUtil.listOrEmpty(mapping.getMaps()),
child -> visitMappingEntry(child, context),
context);
}

/**
* Visit the mapping entry.
*
* @param map
* the bound mapping entry object
* @param context
* the visitor context
* @return {@code true} if the removal was applied or {@code false} otherwise
*/
public boolean visitMappingEntry(MappingEntry map, Context context) {
assert context != null;

// visit props
boolean retval = handle(
TargetType.PROP,
() -> CollectionUtil.listOrEmpty(map.getProps()),
null,
context);

// visit links
retval = retval || handle(
TargetType.LINK,
() -> CollectionUtil.listOrEmpty(map.getLinks()),
null,
context);
return retval;
}

static final class Context {
/**
* Types with an "name" flag.
Expand Down Expand Up @@ -543,8 +485,6 @@ public boolean isApplicableTo(@NonNull Object obj) {
break;
}
case LINK:
case MAPPING:
case MAP:
// do nothing
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
import edu.umd.cs.findbugs.annotations.NonNull;

class ProfileResolutionTests {
private static final String XSLT_PATH = "oscal/src/utils/util/resolver-pipeline/oscal-profile-test-helper.xsl";
private static final String XSLT_PATH = "oscal/src/utils/resolver-pipeline/oscal-profile-test-helper.xsl";
private static final String PROFILE_UNIT_TEST_PATH
= "oscal/src/specifications/profile-resolution/profile-resolution-examples";
private static final String JUNIT_TEST_PATH = "src/test/resources";
Expand Down

0 comments on commit 212aea9

Please sign in to comment.