Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: potential finalizer attack #702

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* OpenFeature provider for flagd.
*/
@Slf4j
@SuppressWarnings("PMD.TooManyStaticImports")
@SuppressWarnings({"PMD.TooManyStaticImports", "checkstyle:NoFinalizer"})
public class FlagdProvider extends EventProvider implements FeatureProvider {
private static final String FLAGD_PROVIDER = "flagD Provider";

Expand All @@ -33,6 +33,10 @@ public class FlagdProvider extends EventProvider implements FeatureProvider {

private EvaluationContext evaluationContext;

protected final void finalize() {
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
}

/**
* Create a new FlagdProvider instance with default options.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,15 @@ private static String distributeValue(final String hashKey, final List<FractionP
}

@Getter
@SuppressWarnings({"checkstyle:NoFinalizer"})
private static class FractionProperty {
private final String variant;
private final int percentage;

protected final void finalize() {
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
}

FractionProperty(final Object from) throws JsonLogicException {
if (!(from instanceof List<?>)) {
throw new JsonLogicException("Property is not an array");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* GoFeatureFlagProvider is the JAVA provider implementation for the feature flag solution GO Feature Flag.
*/
@Slf4j
@SuppressWarnings({"checkstyle:NoFinalizer"})
public class GoFeatureFlagProvider implements FeatureProvider {
public static final long DEFAULT_CACHE_TTL_MS = 1000;
public static final int DEFAULT_CACHE_CONCURRENCY_LEVEL = 1;
Expand All @@ -81,6 +82,10 @@ public class GoFeatureFlagProvider implements FeatureProvider {
private Cache<String, ProviderEvaluation<?>> cache;
private ProviderState state = ProviderState.NOT_READY;

protected final void finalize() {
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
}

/**
* Constructor of the provider.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
* DataCollectorHook is an OpenFeature Hook in charge of sending the usage of the flag to GO Feature Flag.
*/
@Slf4j
@SuppressWarnings({"checkstyle:NoFinalizer"})
public class DataCollectorHook implements Hook {
public static final long DEFAULT_FLUSH_INTERVAL_MS = Duration.ofMinutes(1).toMillis();
public static final int DEFAULT_MAX_PENDING_EVENTS = 10000;
Expand All @@ -45,6 +46,10 @@ public class DataCollectorHook implements Hook {
*/
private final EventsPublisher<Event> eventsPublisher;

protected final void finalize() {
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
}

/**
* Constructor of the hook.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
value = "PATH_TRAVERSAL_IN",
justification = "This is expected to read files based on user input"
)
@SuppressWarnings({"checkstyle:NoFinalizer"})
public class FileBasedFetcher implements RuleFetcher {
private static final Logger log = Logger.getLogger(String.valueOf(FileBasedFetcher.class));
private final JSONObject rules;

protected final void finalize() {
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
}

/**
* Create a file based fetcher give a file URI.
* @param filename URI to a given file.
Expand Down
Loading