Skip to content

Manual Trigger user Audit - #3313

Closed
loghen41 wants to merge 179 commits into
concourse:masterfrom
loghen41:master
Closed

loghen41 wants to merge 179 commits into
concourse:masterfrom
loghen41:master

Conversation

@loghen41

Copy link
Copy Markdown
Contributor

This is in response in part to #2752

It only solves half of the issue, specifically focusing on manual triggers.

On a manual trigger, the user_name of the client is appended to the web log.
This serves as a start for an audit trail for manual triggers

Signed-off-by: Logan Hendricks [email protected]

Ciro S. Costa and others added 2 commits January 17, 2019 07:59
…etric

Previously, `worker state` would report on a per-worker base the state
of the worker:

	worker_state (worker=worker1, state=stalled)
	worker_state (worker=worker2, state=running)
	...

While that works well for our push-based emitters (like Influx and
Datadog), it presents some problems for pull-based ones (like
Prometheus) as we end up needing to catch up with what are workers that
are not around anymore and performing some GC (this could be remediated
by using "const" metrics, but that'd require `emit` to send multiple
metrics in a single event).

Assuming that the goal of the operator is to know whether there are any
workers that are stalled, then a simple per-state gauge can be
adopted, being equally good to pull-based and push-based systems.

ps.: by droping the `worker` dimension of the metric the operator might
lose the ability to quickly determine which worker is stalled (and when
it got to that state).

Signed-off-by: Ciro S. Costa <[email protected]>
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>

@jwntrs jwntrs left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey @loghen41, thanks for getting the ball rolling on auditing, however, we've got some pending changes to job triggering that are going to conflict with your changes here. We are removing TriggerImmediately from the scheduler.

I've been thinking about how we could tackle this a bit more generally. For instance, at this point the accessor knows 1) the API action 2) the user 3) the request params. So maybe it makes sense to log an audit event here (or maybe we should be adding another handler somewhere down the chain).

If this is something you're interested in helping out with that would be awesome.

@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters Thanks for the review. To be honest, I put together this pull request, and then after submitting it, I was looking at some of the upcoming pull requests your team has put together and I truthfully did wonder if my changes would fit into your future roadmap.

I actually had the same thought along the lines that you did. I did wonder if the accessor really had enough of the needed information to log out a proper audit log. (and it seemed somewhat more secure for the accessor itself to log the info, rather than the external modules to have to request the needed audit data from the accessor and log it out themselves).

My only concern is that while for auditing you really want everything logged out that is being accomplished, it can be considered TOO verbose if it's just a general log for all requests that the accessor receives. Do you have any insights into that before I jump into it?

@jwntrs

jwntrs commented Feb 15, 2019

Copy link
Copy Markdown
Contributor

I think we can probably log everything to start and see how bad it is. If we have a flag in the atc to turn auditing on/off then people can use it as needed.

If its too chatty then maybe we let people configure which actions they want to audit?

@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters Sounds good. I got a bit stalled at the end of last week, but I'll be picking it up again today and see what I can accomplished

Logan Hendricks and others added 13 commits February 19, 2019 15:16
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>
#3022

Signed-off-by: James Cooper <[email protected]>
Co-authored-by: Jamie Klassen <[email protected]>
select by color instead of class name

#2520

Signed-off-by: James Cooper <[email protected]>
Co-authored-by: Jamie Klassen <[email protected]>
The worker.Client interface only existed because there were parts of the
code that wanted to choose a worker and then find or create a container
but there were other parts that wanted to use a specific worker and then
find or create container on that worker. There were these two paths but
in order to use the same code, both the pool and worker objects were
adjusted in order to fit this worker Client interface. This commit
removes this dependency by having the pool object find or choose a
worker and then on the worker object find or create a container on that
chosen worker.

Also, get containers are now being placed with the chosen placement
strategy instead of always randomly placing them.

Signed-off-by: Clara Fu <[email protected]>
Signed-off-by: James Cooper <[email protected]>
Co-authored-by: Jamie Klassen <[email protected]>
Signed-off-by: James Cooper <[email protected]>
Co-authored-by: Jamie Klassen <[email protected]>
The resource factory does not create or find a container, it only wraps
a container with the resource interface. The find and creating of a
container happens anywhere that used to call NewResource.

Signed-off-by: Clara Fu <[email protected]>
set up general audit logger on accessor handler
Logs out on a debug level all received api requests with the associated user
first stage in audit process

Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
on merging upstream into branch, conflicts were caused and reversions inserted
fixed all modified files

Signed-off-by: Logan Hendricks <[email protected]>
@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters I just finished a very general audit logger. Sorry that took me a bit longer than expected. I've attached it to the DEBUG level of logging. (cloudfoundry.lager didn't have an option for anything between DEBUG and INFO... so debug seemed more appropriate for that level of verbosity.)

Please feel free to review, and let me know if there are anything you feel I may have missed.

Signed-off-by: Roman Alekseenkov <[email protected]>
@jwntrs

jwntrs commented Feb 27, 2019

Copy link
Copy Markdown
Contributor

@loghen41 it looks the unit tests are failing.

you'll have to go generate ./... in atc/api to regenerate fakes.

@loghen41

Copy link
Copy Markdown
Contributor Author

k, I'll go take care of that. I thought I caught all of them, but must have missed one.

Comment thread atc/api/accessor/handler.go Outdated
ctx := context.WithValue(r.Context(), "accessor", acc)

if acc, ok := acc.(Access); ok {
h.logger.Debug("audit", lager.Data{"action": r.URL.Path, "method": r.Method, "user": acc.UserName(), "parameters": r.URL.Query()})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think logging the full path and method might be too generic. If you look at the way we set up routes, each one has a name (GetJob) and path params (e.g. :team_name).

In the accessorHandler the name gets injected as h.action and the path params are available as r.FormValues (example here). They might also be available as query params but i'm not sure about that.

What if we logged just the h.action and path params along with the UserName. Most of our api requests don't supply many traditional query params, but we could potentially include those as well.

Thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pivotal-jwinters That sounds great to me. I'm grateful to get some feedback on it. as I was looking for something a bit more precise than just stating the full path and method.

I had dived through the different attributes available, but must have missed those. (especially as this is my first time looking through a lot of your codebase)

@jwntrs

jwntrs commented Feb 27, 2019 •

Copy link
Copy Markdown
Contributor

@jama22 you may be interested in this

@vito any opinions on how much we would be logging here?

YoussB and others added 4 commits February 27, 2019 15:10
Signed-off-by: Bishoy Youssef <[email protected]>
Co-authored-by: Ciro S. Costa <[email protected]>
Also refactored the least build containers strategy to no longer deal
with check containers because radar is now always injected with the
random placement strategy.

Signed-off-by: Clara Fu <[email protected]>
added subscription-dispatch tests

Signed-off-by: James Cooper <[email protected]>
Co-authored-by: Jamie Klassen <[email protected]>
vito and others added 23 commits March 14, 2019 12:51
ci: change topgun param BOSH_KEY to BOSH_SSH_KEY for clarity
web: striped animations and pause button colors
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>
set up general audit logger on accessor handler
Logs out on a debug level all received api requests with the associated user
first stage in audit process

Signed-off-by: Logan Hendricks <[email protected]>
Separation of audit package from accessor package for ease of use

Signed-off-by: Logan Hendricks <[email protected]>
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>
set up general audit logger on accessor handler
Logs out on a debug level all received api requests with the associated user
first stage in audit process

Signed-off-by: Logan Hendricks <[email protected]>
on merging upstream into branch, conflicts were caused and reversions inserted
fixed all modified files

Signed-off-by: Logan Hendricks <[email protected]>
Separation of audit package from accessor package for ease of use

Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>
set up general audit logger on accessor handler
Logs out on a debug level all received api requests with the associated user
first stage in audit process

Signed-off-by: Logan Hendricks <[email protected]>
on merging upstream into branch, conflicts were caused and reversions inserted
fixed all modified files

Signed-off-by: Logan Hendricks <[email protected]>
Separation of audit package from accessor package for ease of use

Signed-off-by: Logan Hendricks <[email protected]>
On a manual trigger, the user_name of the client is appended to the web log.
This serves to assist specificaly for an audit trail for manual triggers

Signed-off-by: Logan Hendricks <[email protected]>
set up general audit logger on accessor handler
Logs out on a debug level all received api requests with the associated user
first stage in audit process

Signed-off-by: Logan Hendricks <[email protected]>
on merging upstream into branch, conflicts were caused and reversions inserted
fixed all modified files

Signed-off-by: Logan Hendricks <[email protected]>
Separation of audit package from accessor package for ease of use

Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
It is possible to have a nil object for an accessor when not authenticated with the app
re added nil check in accessor handler, and fixed unit test accordingly

Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
Signed-off-by: Logan Hendricks <[email protected]>
@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters I believe this pull request is now in a finished state. There is a failure in the testflight, but looking at your build history, I was wondering if that is something that is failing off and on by itself potentially due to the 5.0 release? You'll have to let me know.

After following a rebase as you recommended... it appears to be that even more of your teams' commits were brought into my forked repo. Which was kinda the opposite of what we both wanted.

I'm open to whatever would be easiest for you folks. I can attempt to clean up the git history on my end, we can ignore the extra commits, or I could go to the far extreme of blowing away this PR, Reforking the Repo, and cherry picking over the needed changes.

Also, if there are further changes you want me to make, let me know.

Lastly, I've been using this comment system to keep in touch, would it be better to just connect with you on the discord channel you have for the future?

@jwntrs

jwntrs commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

@loghen41 yeah we're basically at a point where I can't even tell what your changes are anymore lol

If you could squash all your changes into a single commit, and have that sitting atop master that would be great. You could cherry pick them over to a new branch, as you say, or try an interactive rebase on the existing branch.

@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters I agree. this PR is basically garbage for git history. Let me see if I can squash them, or do an interactive rebase. I'll avoid cherry picking things over as a last ditch effort.

Sorry again for the level of mess that it's become, I've personally never had this happen before, so I was surprised when it kept getting worse.

@jwntrs

jwntrs commented Mar 15, 2019

Copy link
Copy Markdown
Contributor

haha no worries

@loghen41

Copy link
Copy Markdown
Contributor Author

@pivotal-jwinters After looking at squashing my commits, and doing an interactive rebase... I found that the amount of unneeded and extra commits from my account were pervasive back to almost 180 commits... which seemed far to invasive to try to squash.

One of my main problems I found on this particular Pull Request is that I was working on my master branch of my fork, which means that it's pretty much impossible to reset my files appropriately here. I'll be blowing away my original fork, cherry picking over the changes, and re-creating a pull request (which sadly seems the easiest of all of the options)

I'll close this pull request soon, and open the new one this afternoon. Sorry again for all of the issues.

@loghen41 loghen41 closed this Mar 22, 2019
@loghen41 loghen41 mentioned this pull request Mar 23, 2019
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.