Skip to content

Commit 2e046be

Browse files
authored
Merge pull request #55 from Keyfactor/ab#69253
v1.2.1 approved by Chadd on 91507(https://css-security.lightning.force.com/lightning/r/Case/500Pc00000UfeY5IAJ/view)
2 parents 71fecc2 + ef4db2e commit 2e046be

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.2.1
2+
- fix(management): `K8SNS` management jobs handle `storepath` parsed length is less than expected.
3+
14
# 1.2.0
25

36
## Features

kubernetes-orchestrator-extension/Jobs/JobBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,13 @@ protected K8SJobCertificate InitJobCertificate(dynamic config)
443443

444444
private static bool IsNamespaceStore(string capability)
445445
{
446-
return capability != null && string.IsNullOrEmpty(capability) &&
446+
return !string.IsNullOrEmpty(capability) &&
447447
capability.Contains("K8SNS", StringComparison.OrdinalIgnoreCase);
448448
}
449449

450450
private static bool IsClusterStore(string capability)
451451
{
452-
return capability != null && string.IsNullOrEmpty(capability) &&
452+
return !string.IsNullOrEmpty(capability) &&
453453
capability.Contains("K8SCLUSTER", StringComparison.OrdinalIgnoreCase);
454454
}
455455

kubernetes-orchestrator-extension/Jobs/Management.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,10 @@ private V1Secret HandlePkcs12Secret(ManagementJobConfiguration config, bool remo
281281
{
282282
if (config.OperationType == CertStoreOperationType.Remove)
283283
{
284-
Logger.LogWarning("Secret {Name} not found in Kubernetes so nothing to remove...", KubeSecretName);
284+
Logger.LogWarning("Secret {Name} not found in Kubernetes, nothing to remove...", KubeSecretName);
285285
return null;
286286
}
287-
Logger.LogWarning("Secret {Name} not found in Kubernetes so creating new secret...", KubeSecretName);
287+
Logger.LogWarning("Secret {Name} not found in Kubernetes, creating new secret...", KubeSecretName);
288288
}
289289
}
290290

@@ -548,6 +548,13 @@ private JobResult HandleCreateOrUpdate(string secretType, ManagementJobConfigura
548548
jobCertObj.Alias = config.JobCertificate.Alias;
549549
// Split alias by / and get second to last element KubeSecretType
550550
var splitAlias = jobCertObj.Alias.Split("/");
551+
if (splitAlias.Length < 2)
552+
{
553+
var invalidAliasErrMsg = "Invalid alias format for K8SNS store type. Alias pattern: `<secret_type>/<secret_name>` where `secret_type` is one of 'opaque' or 'tls' and `secret_name` is the name of the secret.";
554+
Logger.LogError(invalidAliasErrMsg);
555+
Logger.LogInformation("End MANAGEMENT job " + config.JobId + " " + invalidAliasErrMsg + " Failed!");
556+
return FailJob(invalidAliasErrMsg, config.JobHistoryId);
557+
}
551558
KubeSecretType = splitAlias[^2];
552559
KubeSecretName = splitAlias[^1];
553560
Logger.LogDebug("Handling managment add job for K8SNS secret type '" + KubeSecretType + "(" + jobCertObj.Alias + ")'...");

0 commit comments

Comments
 (0)