From c3ec4dc4f140e7b79281cabf34935681155ab7a4 Mon Sep 17 00:00:00 2001 From: Mike Cobbett <77053+techcobweb@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:21:05 +0100 Subject: [PATCH] Removed dummy secret in docs so people know it's not a real value they should use Signed-off-by: Mike Cobbett <77053+techcobweb@users.noreply.github.com> --- .secrets.baseline | 21 ++++++++++++++++- dev-instructions.md | 2 +- .../java/dev/galasa/framework/TestRunner.java | 23 ++++++++++++++----- ...FrameworkConfigurationPropertyService.java | 17 ++++++++------ 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index fafda2d67..24a95a0da 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -75,7 +75,26 @@ "name": "TwilioKeyDetector" } ], - "results": {}, + "results": { + "dev-instructions.md": [ + { + "hashed_secret": "77b7ec5b6a79743317504b36fc8f3d74d892321f", + "is_secret": false, + "is_verified": false, + "line_number": 50, + "type": "Secret Keyword", + "verified_result": null + }, + { + "hashed_secret": "3d19b59783a48f4e22f03cb4e69fb165b6a4b40f", + "is_secret": false, + "is_verified": false, + "line_number": 161, + "type": "Secret Keyword", + "verified_result": null + } + ] + }, "version": "0.13.1+ibm.62.dss", "word_list": { "file": null, diff --git a/dev-instructions.md b/dev-instructions.md index 32fe6dcd5..502962b50 100644 --- a/dev-instructions.md +++ b/dev-instructions.md @@ -47,7 +47,7 @@ Add this to your `.zprofile`: # Created the couchdb password using this: #export COUCHDB_PASSWORD=$(openssl rand -base64 10) #echo "Couchdb password for $COUCHDB_USER is $COUCHDB_PASSWORD" - export COUCHDB_PASSWORD="1234asdwergf_asdasd" + export COUCHDB_PASSWORD="????????????????????" export COUCHDB_TOKEN=$(echo -n "${COUCHDB_USER}:${COUCHDB_PASSWORD}" | base64) export GALASA_RAS_TOKEN=${COUCHDB_TOKEN} diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java index 7b9ea744b..00763c5b1 100644 --- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java +++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/TestRunner.java @@ -461,6 +461,8 @@ public void runTest(Properties bootstrapProperties, Properties overridePropertie // *** Record all the CPS properties that were accessed recordCPSProperties(frameworkInitialisation); + saveCPSOverridesAsArtifact(overrideProperties); + // *** If this was a local run, then we will want to remove the run properties // from the DSS immediately // *** for automation, we will let the core manager clean up after a while @@ -817,22 +819,31 @@ public IConfigurationPropertyStoreService getCPS() { return this.cps; } + private void saveCPSOverridesAsArtifact(Properties overrideProperties) { + savePropertiesAsArtifactFile(overrideProperties, "cps_overrides.properties"); + } + private void recordCPSProperties(FrameworkInitialisation frameworkInitialisation) { - try { - Properties record = this.framework.getRecordProperties(); + Properties record = this.framework.getRecordProperties(); + savePropertiesAsArtifactFile(record, "cps_record.properties"); + } + private void savePropertiesAsArtifactFile(Properties props, String filename) { + try { ArrayList propertyNames = new ArrayList<>(); - propertyNames.addAll(record.stringPropertyNames()); + propertyNames.addAll(props.stringPropertyNames()); Collections.sort(propertyNames); StringBuilder sb = new StringBuilder(); String currentNamespace = null; for (String propertyName : propertyNames) { + // Ignore empty property names. Shouldn't happen anyway, but just in case. propertyName = propertyName.trim(); if (propertyName.isEmpty()) { continue; } + // Separate the groups of properties with a new line between namespaces. String[] parts = propertyName.split("\\."); if (!parts[0].equals(currentNamespace)) { if (currentNamespace != null) { @@ -843,16 +854,16 @@ private void recordCPSProperties(FrameworkInitialisation frameworkInitialisation sb.append(propertyName); sb.append("="); - sb.append(record.getProperty(propertyName)); + sb.append(props.getProperty(propertyName)); sb.append("\n"); } IResultArchiveStore ras = this.framework.getResultArchiveStore(); Path rasRoot = ras.getStoredArtifactsRoot(); - Path rasProperties = rasRoot.resolve("framework").resolve("cps_record.properties"); + Path rasProperties = rasRoot.resolve("framework").resolve(filename); Files.createFile(rasProperties, ResultArchiveStoreContentType.TEXT); Files.write(rasProperties, sb.toString().getBytes(StandardCharsets.UTF_8)); } catch (Exception e) { - logger.error("Failed to save the recorded properties", e); + logger.error("Failed to save the properties to file "+filename+" - ignoring.", e); } } diff --git a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/cps/FrameworkConfigurationPropertyService.java b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/cps/FrameworkConfigurationPropertyService.java index 807c01f62..b56393ef7 100644 --- a/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/cps/FrameworkConfigurationPropertyService.java +++ b/galasa-parent/dev.galasa.framework/src/main/java/dev/galasa/framework/internal/cps/FrameworkConfigurationPropertyService.java @@ -197,16 +197,17 @@ private String getValueAndMakeAccessRecord(String key) throws ConfigurationPrope value = overrides.getProperty(key); if (value != null) { - record.put(key, value); + recordCPSActivity(key, value); return value; } - value = cpsStore.getProperty(key); + value = cpsStore.getProperty(key); if (value != null) { - record.put(key, value); + recordCPSActivity(key, value); return value; } - record.put(key, "*** MISSING ***"); + + recordCPSActivity(key, "*** MISSING ***"); return null; } @@ -275,7 +276,7 @@ public Map getPrefixedProperties(@NotNull String prefix) String value = (String) entry.getValue(); if (key.startsWith(fullPrefix)) { - this.record.setProperty(key, value); + recordCPSActivity(key, value); key = key.substring(this.namespace.length() + 1); returnValues.put(key, value); @@ -291,7 +292,7 @@ public Map getPrefixedProperties(@NotNull String prefix) String unPrefixedKey = key.substring(this.namespace.length() + 1); if (!returnValues.containsKey(unPrefixedKey)) { - this.record.setProperty(key, value); + recordCPSActivity(key, value); returnValues.put(unPrefixedKey, value); } @@ -300,5 +301,7 @@ public Map getPrefixedProperties(@NotNull String prefix) return returnValues; } - + private void recordCPSActivity(String key, String valueUsed) { + this.record.setProperty(key, valueUsed); + } } \ No newline at end of file