Skip to content

Commit

Permalink
WFCORE-6347 Revert "temporary" permissiveness of null dependency for …
Browse files Browse the repository at this point in the history
…hasOptionalCapability(...).

Add null parameter checks to prevent misuse.
  • Loading branch information
pferraro committed Feb 14, 2024
1 parent 40cd320 commit d696e73
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
import org.jboss.msc.service.ServiceRegistry;
import org.jboss.msc.service.ServiceRegistryException;
import org.jboss.msc.service.ServiceTarget;
import org.wildfly.common.Assert;
import org.wildfly.security.auth.server.SecurityIdentity;

/**
Expand Down Expand Up @@ -1564,6 +1565,8 @@ private void recordRequirement(RuntimeRequirementRegistration reg, Step step) {

@Override
public boolean hasOptionalCapability(String required, String dependent, String attribute) {
Assert.checkNotNullParam("required", required);
Assert.checkNotNullParam("dependent", dependent);
return requestOptionalCapability(required, dependent, true, activeStep, attribute);
}

Expand All @@ -1572,12 +1575,6 @@ boolean requestOptionalCapability(String required, String dependent, boolean run
assertCapabilitiesAvailable(currentStage);
ensureLocalCapabilityRegistry();
RuntimeCapabilityRegistry registry = managementModel.getCapabilityRegistry();
if (dependent == null) {
// WFCORE-900 we're currently forgiving of this, but only for runtime-only requirements
assert runtimeOnly;
CapabilityScope context = createCapabilityContext(step.address);
return registry.hasCapability(required, context);
}
RuntimeRequirementRegistration registration = createRequirementRegistration(required, dependent, runtimeOnly, step, attribute);
CapabilityScope context = registration.getDependentContext();
if (registry.hasCapability(required, context)) {
Expand All @@ -1590,6 +1587,8 @@ boolean requestOptionalCapability(String required, String dependent, boolean run

@Override
public void requireOptionalCapability(String required, String dependent, String attribute) throws OperationFailedException {
Assert.checkNotNullParam("required", required);
Assert.checkNotNullParam("dependent", dependent);
requireOptionalCapability(required, dependent, activeStep, attribute);
}

Expand Down

0 comments on commit d696e73

Please sign in to comment.