From 141dc9d119b7f35f743a2e2f52b00af10f8d70cd Mon Sep 17 00:00:00 2001 From: Rawlin Peters Date: Wed, 13 May 2020 11:24:57 -0600 Subject: [PATCH] Improve content invalidation audit logging (#4689) * Improve content invalidation audit logging When this API was rewritten to Go, the audit logging was made too terse. Improve it to provide as much information as TO-Perl provided. * Add changelog entry (cherry picked from commit 436b0468d23f731a2f39622f804a13bcd389fedb) --- CHANGELOG.md | 1 + .../traffic_ops_golang/invalidationjobs/invalidationjobs.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2549765306..12a73bf42b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed ORT config generation not using the coalesce_number_v6 Parameter. - Removed audit logging from the `POST /api/x/serverchecks` Traffic Ops API endpoint in order to reduce audit log spam - Fixed the `GET /api/x/jobs` and `GET /api/x/jobs/:id` Traffic Ops API routes to allow falling back to Perl via the routing blacklist +- Fixed audit logging from the `/jobs` APIs to bring them back to the same level of information provided by TO-Perl ### Deprecated/Removed - The Traffic Ops `db/admin.pl` script has now been removed. Please use the `db/admin` binary instead. diff --git a/traffic_ops/traffic_ops_golang/invalidationjobs/invalidationjobs.go b/traffic_ops/traffic_ops_golang/invalidationjobs/invalidationjobs.go index c2ae40c45a..2029aad600 100644 --- a/traffic_ops/traffic_ops_golang/invalidationjobs/invalidationjobs.go +++ b/traffic_ops/traffic_ops_golang/invalidationjobs/invalidationjobs.go @@ -367,7 +367,7 @@ func Create(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) w.Write(append(resp, '\n')) - api.CreateChangeLogRawTx(api.ApiChange, api.Created+"content invalidation job: #"+strconv.FormatUint(*result.ID, 10), inf.User, inf.Tx.Tx) + api.CreateChangeLogRawTx(api.ApiChange, api.Created+" content invalidation job - ID: "+strconv.FormatUint(*result.ID, 10)+" DS: "+*result.DeliveryService+" URL: '"+*result.AssetURL+"' Params: '"+*result.Parameters+"'", inf.User, inf.Tx.Tx) } // Used by PUT requests to `/jobs`, replaces an existing content invalidation job @@ -526,7 +526,7 @@ func Update(w http.ResponseWriter, r *http.Request) { w.Header().Set(http.CanonicalHeaderKey("content-type"), rfc.ApplicationJSON) w.Write(append(resp, '\n')) - api.CreateChangeLogRawTx(api.ApiChange, api.Updated+"content invalidation job: #"+strconv.FormatUint(*job.ID, 10), inf.User, inf.Tx.Tx) + api.CreateChangeLogRawTx(api.ApiChange, api.Updated+" content invalidation job - ID: "+strconv.FormatUint(*job.ID, 10)+" DS: "+*job.DeliveryService+" URL: '"+*job.AssetURL+"' Params: '"+*job.Parameters+"'", inf.User, inf.Tx.Tx) } // Used by DELETE requests to `/jobs`, deletes an existing content invalidation job @@ -612,7 +612,7 @@ func Delete(w http.ResponseWriter, r *http.Request) { w.Header().Set(http.CanonicalHeaderKey("content-type"), rfc.ApplicationJSON) w.Write(append(resp, '\n')) - api.CreateChangeLogRawTx(api.ApiChange, api.Deleted+"content invalidation job: #"+strconv.FormatUint(*result.ID, 10), inf.User, inf.Tx.Tx) + api.CreateChangeLogRawTx(api.ApiChange, api.Deleted+" content invalidation job - ID: "+strconv.FormatUint(*result.ID, 10)+" DS: "+*result.DeliveryService+" URL: '"+*result.AssetURL+"' Params: '"+*result.Parameters+"'", inf.User, inf.Tx.Tx) } func setRevalFlags(d interface{}, tx *sql.Tx) error {