Skip to content

adding workspace_build resource#4636

Merged
Kira-Pilot merged 13 commits into
mainfrom
audit-on-build/kira-pilot
Oct 25, 2022
Merged

adding workspace_build resource#4636
Kira-Pilot merged 13 commits into
mainfrom
audit-on-build/kira-pilot

Conversation

@Kira-Pilot
Copy link
Copy Markdown
Member

@Kira-Pilot Kira-Pilot commented Oct 18, 2022

resolves #4625

We now log start/stop for workspace builds
Screen Shot 2022-10-21 at 2 33 16 PM

Comment thread coderd/audit/request.go Outdated
case database.Workspace:
return typed.Name
case database.WorkspaceBuild:
return string(typed.Transition)

This comment was marked as outdated.

Comment thread coderd/audit/request.go
@Kira-Pilot
Copy link
Copy Markdown
Member Author

@coadler I'm close with this!
Screen Shot 2022-10-19 at 1 15 10 PM

But I want to get the workspace name in this friendly string, which does not exist on the workspace_build resource.

I figured I would just add an optional argument to InitRequest: AlternativeResource and pass that through; however, it seems there aren't optional arguments in Go. Also, maybe that's ugly.

Do you have any ideas?

@Kira-Pilot Kira-Pilot requested a review from coadler October 19, 2022 17:18
@coadler
Copy link
Copy Markdown
Contributor

coadler commented Oct 20, 2022

Audit logs have a field called additional_resources, which is intended for this scenario. I haven't really piped it through yet though. This is where you could put the workspace name!

Comment thread coderd/audit/request.go
return typed.Name
case database.WorkspaceBuild:
// this isn't used
return string(typed.BuildNumber)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ug tell me there's a better way.

Comment thread coderd/audit.go
workspace_bytes := []byte(alog.AdditionalFields)
var workspaceResourceInfo WorkspaceResourceInfo
json.Unmarshal(workspace_bytes, &workspaceResourceInfo)
str += " for workspace " + workspaceResourceInfo.WorkspaceName
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer not to add this here and instead to use the ResourceTarget function.

@Kira-Pilot Kira-Pilot marked this pull request as ready for review October 21, 2022 18:36
@Kira-Pilot Kira-Pilot requested a review from a team as a code owner October 21, 2022 18:36
@Kira-Pilot Kira-Pilot requested review from BrunoQuaresma and removed request for a team October 21, 2022 18:36
Copy link
Copy Markdown
Contributor

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FE and BE code looks good to me! I don't have answers for your questions tho.

Comment thread coderd/database/migrations/000065_add_resource_type_workspace_build.up.sql Outdated
Comment thread coderd/templates.go Outdated
Comment thread coderd/workspacebuilds.go Outdated
@Kira-Pilot Kira-Pilot merged commit 145faf4 into main Oct 25, 2022
@Kira-Pilot Kira-Pilot deleted the audit-on-build/kira-pilot branch October 25, 2022 13:27
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit: log workspace start and stop actions

3 participants