Skip to content

Commit a0a959c

Browse files
authored
feat: better display secret audit values (coder#5801)
1 parent 341b7ca commit a0a959c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

site/src/components/AuditLogRow/AuditLogDiff.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const AuditLogDiff: FC<{ diff: AuditLog["diff"] }> = ({ diff }) => {
4141
styles.diffValueOld,
4242
])}
4343
>
44-
{getDiffValue(valueDiff.old)}
44+
{valueDiff.secret ? "••••••••" : getDiffValue(valueDiff.old)}
4545
</span>
4646
</div>
4747
</div>
@@ -60,7 +60,7 @@ export const AuditLogDiff: FC<{ diff: AuditLog["diff"] }> = ({ diff }) => {
6060
styles.diffValueNew,
6161
])}
6262
>
63-
{getDiffValue(valueDiff.new)}
63+
{valueDiff.secret ? "••••••••" : getDiffValue(valueDiff.new)}
6464
</span>
6565
</div>
6666
</div>

site/src/components/AuditLogRow/AuditLogRow.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
MockAuditLog2,
1111
MockAuditLogWithWorkspaceBuild,
1212
MockAuditLogWithDeletedResource,
13+
MockAuditLogGitSSH,
1314
} from "testHelpers/entities"
1415
import { AuditLogRow, AuditLogRowProps } from "./AuditLogRow"
1516

@@ -72,3 +73,8 @@ export const DeletedResource = Template.bind({})
7273
DeletedResource.args = {
7374
auditLog: MockAuditLogWithDeletedResource,
7475
}
76+
77+
export const SecretDiffValue = Template.bind({})
78+
SecretDiffValue.args = {
79+
auditLog: MockAuditLogGitSSH,
80+
}

site/src/testHelpers/entities.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,22 @@ export const MockAuditLogWithDeletedResource: TypesGen.AuditLog = {
10661066
is_deleted: true,
10671067
}
10681068

1069+
export const MockAuditLogGitSSH: TypesGen.AuditLog = {
1070+
...MockAuditLog,
1071+
diff: {
1072+
private_key: {
1073+
old: "",
1074+
new: "",
1075+
secret: true,
1076+
},
1077+
public_key: {
1078+
old: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINRUPjBSNtOAnL22+r07OSu9t3Lnm8/5OX8bRHECKS9g\n",
1079+
new: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEwoUPJPMekuSzMZyV0rA82TGGNzw/Uj/dhLbwiczTpV\n",
1080+
secret: false,
1081+
},
1082+
},
1083+
}
1084+
10691085
export const MockWorkspaceQuota: TypesGen.WorkspaceQuota = {
10701086
credits_consumed: 0,
10711087
budget: 100,

0 commit comments

Comments
 (0)