Skip to content

chore: rearrange audit logging code into enterprise folder #3741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 31, 2022
Merged

Conversation

coadler
Copy link
Contributor

@coadler coadler commented Aug 29, 2022

Rearranges the auditing code to fit into the new RFC.

@coadler coadler requested a review from spikecurtis August 29, 2022 21:15
@coadler coadler self-assigned this Aug 29, 2022
@coadler coadler requested a review from a team as a code owner August 29, 2022 21:15
@coadler coadler requested review from BrunoQuaresma and removed request for a team August 29, 2022 21:15
type Auditor interface {
Export(ctx context.Context, alog database.AuditLog) error
diff(old, new any) Map
}
Copy link
Contributor

Choose a reason for hiding this comment

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

One missing item is the "noop" implementation of the interface

@coadler coadler requested a review from spikecurtis August 29, 2022 23:28
@BrunoQuaresma
Copy link
Collaborator

What could be good mock values? I was able to get these:

What would be the best values for the following mock?
export const MockAuditLog = {
  id: "123",
  request_id: "1234",
  time: "2022-05-19T16:45:57.122Z",
  organization_id: "fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0",
  ip: "127.0.0.1",
  user_agent: "browser",
  resource_type: "organization",
  resource_id: "123",
  resource_target: "",
  action: "create",
  diff: "",
  status_code: 200,
  additional_fields: "",
  description: "",
  user: MockUser,
  resource: "",
}

@coadler
Copy link
Contributor Author

coadler commented Aug 30, 2022

Does this work?

What would be the best values for the following mock?
export const MockAuditLog = {
  id: "fbd2116a-8961-4954-87ae-e4575bd29ce0",
  request_id: "53bded77-7b9d-4e82-8771-991a34d759f9",
  time: "2022-05-19T16:45:57.122Z",
  organization_id: "fc0774ce-cc9e-48d4-80ae-88f7a4d4a8b0",
  ip: "127.0.0.1",
  user_agent: "browser",
  resource_type: "organization",
  resource_id: "ef8d1cf4-82de-4fd9-8980-047dad6d06b5",
  resource_target: "Bruno's Org",
  action: "create",
  diff: {}, // some random combination diffs
  status_code: 200,
  additional_fields: {},
  description: "Colin Adler updated the organization Bruno's Org",
  user: MockUser,
  resource: {}, // this should be a mock organization since you're using the org type above
}

@BrunoQuaresma
Copy link
Collaborator

That is great, thanks @coadler

@BrunoQuaresma
Copy link
Collaborator

The diff in the mock shows the attribute + old and new values but I see the AuditDiff is only a struct with the old and diff values. Should we add the attribute name as well?

Screen Shot 2022-08-30 at 17 06 53

@coadler
Copy link
Contributor Author

coadler commented Aug 30, 2022

The attribute name is the key in the diff map!

@BrunoQuaresma
Copy link
Collaborator

Ahh I see so it is something like:

diff: {
   name: {
      old: "Bruno",
      new: "Bruno edited"
   }
}

Is that right?

@coadler
Copy link
Contributor Author

coadler commented Aug 30, 2022

yep!

Copy link
Collaborator

@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 looks good to me

@coadler coadler enabled auto-merge (squash) August 31, 2022 21:05
@coadler coadler merged commit 00da01f into main Aug 31, 2022
@coadler coadler deleted the colin/auditv2 branch August 31, 2022 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants