Skip to content

Commit 572df60

Browse files
authored
fix: potential finalizer attack (#702)
Signed-off-by: Todd Baert <[email protected]>
1 parent 49f35b2 commit 572df60

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* OpenFeature provider for flagd.
2323
*/
2424
@Slf4j
25-
@SuppressWarnings("PMD.TooManyStaticImports")
25+
@SuppressWarnings({"PMD.TooManyStaticImports", "checkstyle:NoFinalizer"})
2626
public class FlagdProvider extends EventProvider implements FeatureProvider {
2727
private static final String FLAGD_PROVIDER = "flagD Provider";
2828

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

3434
private EvaluationContext evaluationContext;
3535

36+
protected final void finalize() {
37+
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
38+
}
39+
3640
/**
3741
* Create a new FlagdProvider instance with default options.
3842
*/

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/resolver/process/targeting/Fractional.java

+5
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,15 @@ private static String distributeValue(final String hashKey, final List<FractionP
9393
}
9494

9595
@Getter
96+
@SuppressWarnings({"checkstyle:NoFinalizer"})
9697
private static class FractionProperty {
9798
private final String variant;
9899
private final int percentage;
99100

101+
protected final void finalize() {
102+
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
103+
}
104+
100105
FractionProperty(final Object from) throws JsonLogicException {
101106
if (!(from instanceof List<?>)) {
102107
throw new JsonLogicException("Property is not an array");

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/GoFeatureFlagProvider.java

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
* GoFeatureFlagProvider is the JAVA provider implementation for the feature flag solution GO Feature Flag.
6060
*/
6161
@Slf4j
62+
@SuppressWarnings({"checkstyle:NoFinalizer"})
6263
public class GoFeatureFlagProvider implements FeatureProvider {
6364
public static final long DEFAULT_CACHE_TTL_MS = 1000;
6465
public static final int DEFAULT_CACHE_CONCURRENCY_LEVEL = 1;
@@ -81,6 +82,10 @@ public class GoFeatureFlagProvider implements FeatureProvider {
8182
private Cache<String, ProviderEvaluation<?>> cache;
8283
private ProviderState state = ProviderState.NOT_READY;
8384

85+
protected final void finalize() {
86+
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
87+
}
88+
8489
/**
8590
* Constructor of the provider.
8691
*

providers/go-feature-flag/src/main/java/dev/openfeature/contrib/providers/gofeatureflag/hook/DataCollectorHook.java

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
* DataCollectorHook is an OpenFeature Hook in charge of sending the usage of the flag to GO Feature Flag.
3434
*/
3535
@Slf4j
36+
@SuppressWarnings({"checkstyle:NoFinalizer"})
3637
public class DataCollectorHook implements Hook {
3738
public static final long DEFAULT_FLUSH_INTERVAL_MS = Duration.ofMinutes(1).toMillis();
3839
public static final int DEFAULT_MAX_PENDING_EVENTS = 10000;
@@ -45,6 +46,10 @@ public class DataCollectorHook implements Hook {
4546
*/
4647
private final EventsPublisher<Event> eventsPublisher;
4748

49+
protected final void finalize() {
50+
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
51+
}
52+
4853
/**
4954
* Constructor of the hook.
5055
*

providers/jsonlogic-eval-provider/src/main/java/dev/openfeature/contrib/providers/jsonlogic/FileBasedFetcher.java

+5
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@
1919
value = "PATH_TRAVERSAL_IN",
2020
justification = "This is expected to read files based on user input"
2121
)
22+
@SuppressWarnings({"checkstyle:NoFinalizer"})
2223
public class FileBasedFetcher implements RuleFetcher {
2324
private static final Logger log = Logger.getLogger(String.valueOf(FileBasedFetcher.class));
2425
private final JSONObject rules;
2526

27+
protected final void finalize() {
28+
// DO NOT REMOVE, spotbugs: CT_CONSTRUCTOR_THROW
29+
}
30+
2631
/**
2732
* Create a file based fetcher give a file URI.
2833
* @param filename URI to a given file.

0 commit comments

Comments
 (0)