Skip to content

Commit ef3698b

Browse files
committed
concord-server: use validated name when updating secrets, fix formatting
1 parent a9147e0 commit ef3698b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

server/impl/src/main/java/com/walmartlabs/concord/server/org/secret/SecretManager.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,26 +368,24 @@ public void update(UUID orgId, String secretName, SecretUpdateParams params) {
368368
newEncryptedData = null;
369369
hashAlgorithm = null;
370370
}
371-
if(newProjectIds == null || newProjectIds.isEmpty()){
371+
if (newProjectIds == null || newProjectIds.isEmpty()) {
372372
policyManager.checkEntity(e.getOrgId(), null, EntityType.SECRET, EntityAction.UPDATE, newOwner,
373373
PolicyUtils.secretToMap(e.getOrgId(), e.getName(), e.getType(), e.getVisibility(), e.getStoreType()));
374374
} else {
375-
newProjectIds.stream().forEach(newProjectId -> {
376-
policyManager.checkEntity(e.getOrgId(), newProjectId, EntityType.SECRET, EntityAction.UPDATE, newOwner,
377-
PolicyUtils.secretToMap(e.getOrgId(), e.getName(), e.getType(), e.getVisibility(), e.getStoreType()));
378-
});
375+
newProjectIds.forEach(newProjectId ->
376+
policyManager.checkEntity(e.getOrgId(), newProjectId, EntityType.SECRET, EntityAction.UPDATE, newOwner,
377+
PolicyUtils.secretToMap(e.getOrgId(), e.getName(), e.getType(), e.getVisibility(), e.getStoreType())));
379378
}
380379

381380
String newName = validateName(params.newName(), newOrgId, e);
382-
383381
SecretType finalNewType = newType;
384382
secretDao.tx(tx -> {
385383
if (newOrgId != null) {
386384
// update repository mapping to null when org is changing
387385
repositoryDao.clearSecretMappingBySecretId(tx, e.getId());
388386
}
389387

390-
secretDao.update(tx, e.getId(), params.newName(), newOwner != null ? newOwner.getId() : null,
388+
secretDao.update(tx, e.getId(), newName, newOwner != null ? newOwner.getId() : null,
391389
finalNewType, newEncryptedData, params.newVisibility(), newOrgId, hashAlgorithm);
392390
secretDao.updateSecretProjects(tx, e.getId(), params.removeProjectLink() ? Collections.emptySet() : newProjectIds);
393391
});

0 commit comments

Comments
 (0)