Skip to content

Commit 7c7bfc0

Browse files
committed
Fix GetShortHash, old ShortHash handled length incorrectly so this matches the old functionality now
1 parent 1215d24 commit 7c7bfc0

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/Contrast.K8s.AgentOperator/Core/HashHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static string GetShortHash(string text)
1414
using var sha256 = SHA256.Create();
1515
var bytes = Encoding.UTF8.GetBytes(text);
1616
var hash = sha256.ComputeHash(bytes);
17-
return Convert.ToHexStringLower(hash, 0, 8);
17+
return Convert.ToHexStringLower(hash, 0, 5);
1818
}
1919

2020
public static string Sha256(string text)

src/Contrast.K8s.AgentOperator/Core/Reactions/Secrets/AgentConnectionVolumeSecretHandler.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ private async Task<string> CreateDerivedSecretHash(ResourceIdentityPair<AgentCon
147147
}
148148
}
149149

150-
using var sha256 = SHA256.Create();
151-
var bytes = sha256.ComputeHash(Encoding.ASCII.GetBytes(secretKeyHashes.ToString()));
152-
return Convert.ToHexStringLower(bytes);
150+
return HashHelper.Sha256(secretKeyHashes.ToString());
153151
}
154152

155153
private async Task<byte[]?> CreateLiveConfig(ResourceIdentityPair<AgentConnectionResource> connectionResource)

tests/Contrast.K8s.AgentOperator.FunctionalTests/Scenarios/Injection/InitContainerOverrideTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task When_any_overrides_are_applied_a_debugging_env_var_should_be_a
3737
var container = result.Spec.InitContainers.Single(x => x.Name == "contrast-init");
3838
var env = container.Env;
3939

40-
env.Should().ContainSingle(x => x.Name == "CONTRAST_DEBUGGING_SECURITY_CONTEXT_TAINTED").Which.Value.Should().Be("True");
40+
env.Should().ContainSingle(x => x.Name == "CONTRAST_DEBUGGING_SECURITY_CONTEXT_TAINTED").Which.Value.Should().Be("true");
4141
}
4242
}
4343

0 commit comments

Comments
 (0)