-
Notifications
You must be signed in to change notification settings - Fork 0
Using DataSet view for Builders #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
ad523fd
6055291
33c9635
b183533
f133db5
0da7972
95c0103
4b08885
9404a37
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| package io.appform.databuilderframework.model; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.common.base.Predicates; | ||
| import com.google.common.base.Strings; | ||
| import com.google.common.collect.Maps; | ||
| import io.appform.databuilderframework.engine.DataSetAccessor; | ||
| import io.appform.databuilderframework.engine.Utils; | ||
| import lombok.val; | ||
| import org.hibernate.validator.constraints.NotEmpty; | ||
|
|
||
| import javax.validation.constraints.NotNull; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.concurrent.ConcurrentHashMap; | ||
| import java.util.concurrent.locks.StampedLock; | ||
| import java.util.function.Supplier; | ||
|
|
||
| /** | ||
| * Working set for data | ||
| * Contains all the data that has been provided by the system as well as those generated by the system. | ||
| */ | ||
| public class DataSetView extends DataSet { | ||
|
|
||
| private final DataSet dataSet; | ||
| private final Set<String> allowedKeys; | ||
|
|
||
| public DataSetView(final DataSet dataSet, | ||
| final Set<String> allowedKeys) { | ||
| this.dataSet = dataSet; | ||
| this.allowedKeys = allowedKeys; | ||
| } | ||
|
|
||
| public DataSetView add(String dataName, Data data) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| public DataSetView add(final Collection<Data> data) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| public <T extends Data> DataSetView add(T data) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| public Map<String, Data> filter(final Collection<String> requiredKeys) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| public Data get(final String name) { | ||
| if (allowedKeys.contains(name)) { | ||
| return dataSet.get(name); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| public boolean containsAll(final Collection<String> requiredKeys) { | ||
| // TODO Fix this. Should requiredKeys be filtered on allowedKeys ??? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SECURITY: The DataSetView implementation in src/main/java/io/appform/databuilderframework/model/DataSetView.java contains a TODO comment on line 60 that indicates a potential security vulnerability. The containsAll() method does not properly filter the requiredKeys against allowedKeys, which could allow a builder to check for the existence of keys it shouldn't have access to. This information disclosure vulnerability could be exploited if a malicious DataBuilder checks for existence of data it shouldn't be able to see. |
||
| return dataSet.containsAll(requiredKeys); | ||
| } | ||
|
|
||
| public void copyInto(final Map<String, Data> outMap, Collection<String> excludedKeys) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| public DataSetAccessor accessor() { | ||
| return accessor(this); | ||
| } | ||
|
|
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CODE_MAINTAINABILTIY: The DataSetView implementation doesn't properly override all methods from DataSet, which could lead to unexpected behavior. Specifically, methods like deepCopy(), merge(), and other common operations are missing, which violates the Liskov Substitution Principle (LSP), a key SOLID principle. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ public void testHomePageMTOpt() throws Exception { | |
| private void runHomePageTest(DataFlowExecutor executor) throws Exception { | ||
| val request = new HomePageRequest("2321312312", "2323454", "Blah".getBytes()); | ||
| val stopwatch = Stopwatch.createStarted(); | ||
| for(long i = 0; i < 100_000; i++) { | ||
| for(long i = 0; i < 10000_000; i++) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| HomePageResponse response = executor.run(homePageDataFlow, request).get(HomePageResponse.class); | ||
| Assert.assertNotNull(response); | ||
| //System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(response)); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERROR: The
DataSetViewclass extendsDataSetbut doesn't properly implement or override several methods. It throws UnsupportedOperationException for methods like add(), filter(), and copyInto() but fails to annotate them with @OverRide. This makes the class hierarchy error-prone and can cause confusion about which methods are actually overriding parent methods versus just hiding them.