diff --git a/.github/workflows/check-branch.yml b/.github/workflows/check-branch.yml
index 4c087e59..2332f0d0 100644
--- a/.github/workflows/check-branch.yml
+++ b/.github/workflows/check-branch.yml
@@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Comment PR
- if: github.base_ref == 'master' && github.head_ref != 'next'
+ if: github.base_ref == 'master' && github.head_ref != 'staging'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
- We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
+ We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch.
- name: Check branch
- if: github.base_ref == 'master' && github.head_ref != 'next'
+ if: github.base_ref == 'master' && github.head_ref != 'staging'
run: |
- echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the next branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
+ echo "ERROR: We regret to inform you that you are currently not able to merge your changes into the master branch due to restrictions applied by our SRE team. To proceed with merging your changes, we kindly request that you create a pull request from the staging branch. Our team will then review the changes and work with you to ensure a successful merge into the master branch."
exit 1
diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml
new file mode 100644
index 00000000..049c02f4
--- /dev/null
+++ b/.github/workflows/secrets-scan.yml
@@ -0,0 +1,29 @@
+name: Secrets Scan
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+jobs:
+ security-secrets:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: '2'
+ ref: '${{ github.event.pull_request.head.ref }}'
+ - run: |
+ git reset --soft HEAD~1
+ - name: Install Talisman
+ run: |
+ # Download Talisman
+ wget https://github.com/thoughtworks/talisman/releases/download/v1.37.0/talisman_linux_amd64 -O talisman
+
+ # Checksum verification
+ checksum=$(sha256sum ./talisman | awk '{print $1}')
+ if [ "$checksum" != "8e0ae8bb7b160bf10c4fa1448beb04a32a35e63505b3dddff74a092bccaaa7e4" ]; then exit 1; fi
+
+ # Make it executable
+ chmod +x talisman
+ - name: Run talisman
+ run: |
+ # Run Talisman with the pre-commit hook
+ ./talisman --githook pre-commit
\ No newline at end of file
diff --git a/.talismanrc b/.talismanrc
index 7cd3cd8c..c7edb88f 100644
--- a/.talismanrc
+++ b/.talismanrc
@@ -1 +1,5 @@
threshold: medium
+fileignoreconfig:
+- filename: .github/workflows/secrets-scan.yml
+ checksum: d79ec3f3288964f7d117b9ad319a54c0ebc152e35f69be8fde95522034fdfb2a
+version: "1.0"
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 579e0db1..7068efe5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -201,9 +201,24 @@
slf4j-simple
1.7.36
+
+
+ io.github.cdimascio
+ java-dotenv
+ 5.2.2
+
-
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ 2.1.0
+
+
+
diff --git a/src/test/java/com/contentstack/sdk/Credentials.java b/src/test/java/com/contentstack/sdk/Credentials.java
index e6dce57f..ea26750e 100644
--- a/src/test/java/com/contentstack/sdk/Credentials.java
+++ b/src/test/java/com/contentstack/sdk/Credentials.java
@@ -1,13 +1,12 @@
package com.contentstack.sdk;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.rmi.AccessException;
import java.util.Arrays;
-import java.util.Properties;
+import io.github.cdimascio.dotenv.Dotenv;
public class Credentials {
- private static final Properties properties = new Properties();
+
+ static Dotenv env = getEnv();
private static String envChecker() {
String githubActions = System.getenv("GITHUB_ACTIONS");
@@ -18,24 +17,25 @@ private static String envChecker() {
}
}
- static {
- try (FileInputStream inputStream = new FileInputStream("src/test/resources/test-config.properties")) {
- properties.load(inputStream);
- } catch (IOException e) {
- System.err.println("Error loading properties file: " + e.getMessage());
- }
- }
+ public static Dotenv getEnv() {
+ env = Dotenv.configure()
+ .directory("src/test/resources")
+ .filename("env") // instead of '.env', use 'env'
+ .load();
+
+ return Dotenv.load();
+ }
- public static final String HOST = properties.getProperty("HOST", "cdn.contentstack.io");
- public static final String API_KEY = properties.getProperty("API_KEY", "");
- public static final String DELIVERY_TOKEN = properties.getProperty("DELIVERY_TOKEN", "");
- public static final String ENVIRONMENT = properties.getProperty("ENVIRONMENT", "env1");
- public static final String CONTENT_TYPE = properties.getProperty("contentType", "product");
- public static final String ENTRY_UID = properties.getProperty("assetUid", "");
- public static final String VARIANT_UID = properties.getProperty("variantUid", "");
+ public static final String HOST = env.get("HOST", "cdn.contentstack.io");
+ public static final String API_KEY = env.get("API_KEY", "");
+ public static final String DELIVERY_TOKEN = env.get("DELIVERY_TOKEN", "");
+ public static final String ENVIRONMENT = env.get("ENVIRONMENT", "env1");
+ public static final String CONTENT_TYPE = env.get("contentType", "product");
+ public static final String ENTRY_UID = env.get("assetUid", "");
+ public static final String VARIANT_UID = env.get("variantUid", "");
public final static String[] VARIANTS_UID;
static {
- String variantsUidString = properties.getProperty("variantsUid");
+ String variantsUidString = env.get("variantsUid");
if (variantsUidString != null && !variantsUidString.trim().isEmpty()) {
VARIANTS_UID = Arrays.stream(variantsUidString.split(","))