Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

Commit

Permalink
Removed dummy secret in docs so people know it's not a real value the…
Browse files Browse the repository at this point in the history
…y should use

Signed-off-by: Mike Cobbett <[email protected]>
  • Loading branch information
techcobweb committed Aug 8, 2024
1 parent 1f3aa6c commit c3ec4dc
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 15 deletions.
21 changes: 20 additions & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion dev-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<String> 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) {
Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -275,7 +276,7 @@ public Map<String, String> 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);
Expand All @@ -291,7 +292,7 @@ public Map<String, String> 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);
}
Expand All @@ -300,5 +301,7 @@ public Map<String, String> getPrefixedProperties(@NotNull String prefix)
return returnValues;
}


private void recordCPSActivity(String key, String valueUsed) {
this.record.setProperty(key, valueUsed);
}
}

0 comments on commit c3ec4dc

Please sign in to comment.