Skip to content

Java local bucketing changes - #15

Merged
chantalchung merged 46 commits into
mainfrom
java-local-bucketing-changes
Sep 22, 2022
Merged

Java local bucketing changes#15
chantalchung merged 46 commits into
mainfrom
java-local-bucketing-changes

Conversation

@kaushalkapasi

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread example/settings.gradle
@@ -1 +1,3 @@
rootProject.name = "java-server-sdk-example-app" No newline at end of file
rootProject.name = "java-server-sdk-example-app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Vulnerability:

pkg:maven/org.springframework.boot/spring-boot-starter-web@2.7.0

1 Critical, 0 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies

Components
    pkg:maven/org.springframework/spring-web@5.3.20
      CRITICAL Vulnerabilities (1)

        Deserialization of Untrusted Data

        Pivotal Spring Framework through 5.3.16 suffers from a potential remote code execution (RCE) issue if used for Java deserialization of untrusted data. Depending on how the library is implemented within a product, this issue may or not occur, and authentication may be required. NOTE: the vendor's position is that untrusted data is not an intended use case. The product's behavior will not be changed because some users rely on deserialization of trusted data.

        CVSS Score: 9.8

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

        CWE: CWE-502


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Comment thread example/settings.gradle
@@ -1 +1,3 @@
rootProject.name = "java-server-sdk-example-app" No newline at end of file
rootProject.name = "java-server-sdk-example-app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severe Vulnerability:

pkg:maven/org.springframework.boot/spring-boot-starter-thymeleaf@2.7.0

0 Critical, 5 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies

Components
    pkg:maven/org.unbescape/unbescape@1.1.6.RELEASE
      SEVERE Vulnerabilities (5)
        sonatype-2014-0026

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        CVSS Score: 6.5

        CVSS Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N

        CWE: CWE-79

        CVE-2019-11358

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        jQuery before 3.4.0, as used in Drupal, Backdrop CMS, and other products, mishandles jQuery.extend(true, {}, ...) because of Object.prototype pollution. If an unsanitized source object contained an enumerable proto property, it could extend the native Object.prototype.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-1321

        CVE-2020-11023

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        In jQuery versions greater than or equal to 1.0.3 and before 3.5.0, passing HTML containing <option> elements from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        sonatype-2020-0187

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        CVE-2021-23413

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        This affects the package jszip before 3.7.0. Crafting a new zip file with filenames set to Object prototype values (e.g proto, toString, etc) results in a returned object with a modified prototype instance.

        CVSS Score: 5.3

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

        CWE: CWE-1321


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Comment thread example/settings.gradle
@@ -1 +1,3 @@
rootProject.name = "java-server-sdk-example-app" No newline at end of file
rootProject.name = "java-server-sdk-example-app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severe Vulnerability:

pkg:maven/org.springframework.boot/spring-boot-starter-thymeleaf@2.7.0

0 Critical, 4 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies

Components
    pkg:maven/org.thymeleaf.extras/thymeleaf-extras-java8time@3.0.4.RELEASE
      SEVERE Vulnerabilities (4)
        CVE-2019-11358

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        jQuery before 3.4.0, as used in Drupal, Backdrop CMS, and other products, mishandles jQuery.extend(true, {}, ...) because of Object.prototype pollution. If an unsanitized source object contained an enumerable proto property, it could extend the native Object.prototype.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-1321

        CVE-2020-11023

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        In jQuery versions greater than or equal to 1.0.3 and before 3.5.0, passing HTML containing <option> elements from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        sonatype-2020-0187

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        CVE-2021-23413

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        This affects the package jszip before 3.7.0. Crafting a new zip file with filenames set to Object prototype values (e.g proto, toString, etc) results in a returned object with a modified prototype instance.

        CVSS Score: 5.3

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

        CWE: CWE-1321


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

Comment thread example/settings.gradle
@@ -1 +1,3 @@
rootProject.name = "java-server-sdk-example-app" No newline at end of file
rootProject.name = "java-server-sdk-example-app"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severe Vulnerability:

pkg:maven/org.springframework.boot/spring-boot-starter-thymeleaf@2.7.0

0 Critical, 5 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies

Components
    pkg:maven/org.attoparser/attoparser@2.0.5.RELEASE
      SEVERE Vulnerabilities (5)
        sonatype-2014-0026

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        CVSS Score: 6.5

        CVSS Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:H/A:N

        CWE: CWE-79

        CVE-2019-11358

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        jQuery before 3.4.0, as used in Drupal, Backdrop CMS, and other products, mishandles jQuery.extend(true, {}, ...) because of Object.prototype pollution. If an unsanitized source object contained an enumerable proto property, it could extend the native Object.prototype.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-1321

        CVE-2020-11023

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        In jQuery versions greater than or equal to 1.0.3 and before 3.5.0, passing HTML containing <option> elements from untrusted sources - even after sanitizing it - to one of jQuery's DOM manipulation methods (i.e. .html(), .append(), and others) may execute untrusted code. This problem is patched in jQuery 3.5.0.

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        sonatype-2020-0187

        Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')

        CVSS Score: 6.1

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

        CWE: CWE-79

        CVE-2021-23413

        Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')

        This affects the package jszip before 3.7.0. Crafting a new zip file with filenames set to Object prototype values (e.g proto, toString, etc) results in a returned object with a modified prototype instance.

        CVSS Score: 5.3

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L

        CWE: CWE-1321


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

kaushalkapasi and others added 10 commits August 30, 2022 15:01
fix javadoc errors and unit test failures
…ult values for cloud bucketing. simplify DVC API Client to support both Cloud and Local bucketing requests
… polling interval. add Etag checking to config requests. update DVCClient (local) to not initialize unused DVC API Client
…ment Manager to handle a 304 - Not Modified response from project config cdn.
Comment thread example/build.gradle
// Run `./gradlew build` in the root directory (`cd .. && ./gradlew build`) to build the local version of the SDK
implementation project(':java-server-sdk')

testImplementation 'org.springframework.boot:spring-boot-starter-test'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Critical Vulnerability:

pkg:maven/org.springframework.boot/spring-boot-starter@2.7.0

1 Critical, 1 Severe, 0 Moderate, 0 Unknown vulnerabilities have been found across 1 dependencies

Components
    pkg:maven/org.yaml/snakeyaml@1.30
      CRITICAL Vulnerabilities (1)

        Uncontrolled Resource Consumption

        The package org.yaml:snakeyaml from 0 and before 1.31 are vulnerable to Denial of Service (DoS) due missing to nested depth limitation for collections.

        CVSS Score: 7.5

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

        CWE: CWE-400

      SEVERE Vulnerabilities (1)

        Stack-based Buffer Overflow

        Using snakeYAML to parse untrusted YAML files may be vulnerable to Denial of Service attacks (DOS). If the parser is running on user supplied input, an attacker may supply content that causes the parser to crash by stack-overflow.

        CVSS Score: 6.5

        CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

        CWE: CWE-121


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

kaushalkapasi and others added 17 commits September 8, 2022 12:28
…cloud

split DVCOptions into Cloud and Bucketing Options that implement a common interface
Dvc 4209 event queue local bucketing methods
DVC-4412: implement EventQueueManager and track
DVC-4450: add event queue options and pass to initEventQueue
DVC-4466 Add Error Handling to Java Local Bucketing SDK
Comment thread example/gradle/wrapper/gradle-wrapper.properties
Comment on lines +17 to +18
DVCCloudClient dvcCloud;
DVCLocalClient dvcLocal;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have separate example apps for Local / Cloud?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think the example app is simple enough that it can be kept together! I did add a custom track event button though

Comment thread gradlew
Comment thread gradlew.bat
Comment thread src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java Outdated
Comment on lines +55 to +57
userString = OBJECT_MAPPER.writeValueAsString(user);

bucketedUserConfig = localBucketing.generateBucketedConfig(serverKey, userString);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is a common action, might make sense to move this logic to the generateBucketedConfig method.

*/
public <T> Variable<T> variable(User user, String key, T defaultValue) {
validateUser(user);
localBucketing.setPlatformData(user.getPlatformData().toString());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again this should be done in a constructor somewhere.

Comment thread src/main/java/com/devcycle/sdk/server/local/api/DVCLocalClient.java
Comment thread src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java Outdated
Comment thread src/main/java/com/devcycle/sdk/server/local/managers/EventQueueManager.java Outdated
Comment thread src/main/java/com/devcycle/sdk/server/local/model/DVCLocalOptions.java Outdated
…onstructor, parse user logic moved to generateBucketedConfig, and cleanup example app
…ersion of DVC Bucketing WASM file before gradle assemble task is called
}
@Builder.Default
@JsonProperty("sdkVersion")
private String sdkVersion = "1.1.0";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway to pull this from the Gradle or something so we don't have to manually update this all the time?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting the sdkVersion from the build.gradle file now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like its still manually defined here? any way to have this populate the version during build time? or dynamically at run-time?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've followed this: https://stackoverflow.com/questions/37642837/gradle-make-build-version-available-to-java
So we're getting the sdkVersion this way: User.class.getPackage().getImplementationVersion()

private void publishEvents(String serverKey, FlushPayload flushPayload) throws InterruptedException {
Thread publishEventsThread = new Thread(new Runnable() {
@Override
public void run() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this callback on a different thread? or the same as the calling thread? just worried about threading calling WASM.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, not sure if I got what you're asking completely but I think when we do publishEventsThread.start() it creates a new thread which then does run() on that newly created thread
https://www.geeksforgeeks.org/difference-between-thread-start-and-thread-run-in-java/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaushalkapasi do we have any thread locking around the calls to WASM?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we currently don't... this is the only area where we are use threads to interact with WASM for the onPayloadSuccess / onPayloadFailure callbacks

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it should be ok... but this is potentially risky, we should probably only call WASM from the same thread.

@chantalchung
chantalchung marked this pull request as ready for review September 22, 2022 17:54
@chantalchung
chantalchung merged commit 2f87c56 into main Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants