-
Notifications
You must be signed in to change notification settings - Fork 43
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
add all edition reports for content workflow and edition churn #1917
Changes from all commits
f4182ee
3c7c331
89152c2
2b9f143
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class AllContentWorkflowPresenter < CSVPresenter | ||
def initialize(scope = Edition.all) | ||
super(scope) | ||
self.column_headings = %i[ | ||
content_title | ||
content_slug | ||
content_url | ||
current_status | ||
stage | ||
format | ||
current_assignee | ||
created_at | ||
date_created | ||
time_created | ||
] | ||
end | ||
|
||
private | ||
|
||
def build_csv(csv) | ||
csv << column_headings.collect { |ch| ch.to_s.humanize } | ||
scope.each do |item| | ||
item.actions.each do |action| | ||
csv << [ | ||
item.title, | ||
item.slug, | ||
"#{Plek.website_root}/#{item.slug}", | ||
item.state, | ||
action.request_type, | ||
item.format, | ||
item.assignee, | ||
action.created_at.to_fs(:db), | ||
action.created_at.to_date.to_s, | ||
action.created_at.to_fs(:time), | ||
] | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class AllEditionChurnPresenter < CSVPresenter | ||
def initialize(scope = Edition.all) | ||
super(scope) | ||
self.column_headings = %i[ | ||
id | ||
panopticon_id | ||
name | ||
slug | ||
state | ||
editioned_on | ||
version_number | ||
date_created | ||
time_created | ||
] | ||
end | ||
|
||
private | ||
|
||
def get_value(header, edition) | ||
case header | ||
when :name | ||
edition.title | ||
when :editioned_on | ||
edition.created_at.iso8601 | ||
when :date_created | ||
edition.created_at.to_date.to_s | ||
when :time_created | ||
edition.created_at.to_fs(:time) | ||
else | ||
super | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,36 @@ | ||
{ | ||
"ignored_warnings": [ | ||
{ | ||
"warning_type": "Redirect", | ||
"warning_code": 18, | ||
"fingerprint": "2cb25751c6a39d8b813d792d58ba4f1fe596aa00d263284ffe5ecef8a546c88b", | ||
"check_name": "Redirect", | ||
"message": "Possible unprotected redirect", | ||
"file": "app/controllers/reports_controller.rb", | ||
"line": 21, | ||
"link": "https://brakemanscanner.org/docs/warning_types/redirect/", | ||
"code": "redirect_to(Report.new(\"all_edition_churn\").url, :allow_other_host => true)", | ||
"render_path": null, | ||
"location": { | ||
"type": "method", | ||
"class": "ReportsController", | ||
"method": "all_edition_churn" | ||
}, | ||
"user_input": "Report.new(\"all_edition_churn\").url", | ||
"confidence": "High", | ||
"cwe_id": [ | ||
601 | ||
], | ||
"note": "" | ||
}, | ||
{ | ||
"warning_type": "Redirect", | ||
"warning_code": 18, | ||
"fingerprint": "4de24c49b5d87e19ef510a17b4952468eaac4f2bfdcf3d5a67507cf694c25c93", | ||
"check_name": "Redirect", | ||
"message": "Possible unprotected redirect", | ||
"file": "app/controllers/reports_controller.rb", | ||
"line": 25, | ||
"line": 33, | ||
"link": "https://brakemanscanner.org/docs/warning_types/redirect/", | ||
"code": "redirect_to(Report.new(\"all_urls\").url, :allow_other_host => true)", | ||
"render_path": null, | ||
|
@@ -23,6 +46,29 @@ | |
], | ||
"note": "This is a redirect to AWS S3 for file download, unlikely to be dangerous." | ||
}, | ||
{ | ||
"warning_type": "Redirect", | ||
"warning_code": 18, | ||
"fingerprint": "605ea82aeb307735d184ae89ae7300b2571376340aa1cd7d48c1c79232f6e7d2", | ||
"check_name": "Redirect", | ||
"message": "Possible unprotected redirect", | ||
"file": "app/controllers/reports_controller.rb", | ||
"line": 29, | ||
"link": "https://brakemanscanner.org/docs/warning_types/redirect/", | ||
"code": "redirect_to(Report.new(\"all_content_workflow\").url, :allow_other_host => true)", | ||
"render_path": null, | ||
"location": { | ||
"type": "method", | ||
"class": "ReportsController", | ||
"method": "all_content_workflow" | ||
}, | ||
"user_input": "Report.new(\"all_content_workflow\").url", | ||
"confidence": "High", | ||
"cwe_id": [ | ||
601 | ||
], | ||
"note": "" | ||
}, | ||
{ | ||
"warning_type": "Dynamic Render Path", | ||
"warning_code": 15, | ||
|
@@ -107,7 +153,7 @@ | |
"check_name": "Redirect", | ||
"message": "Possible unprotected redirect", | ||
"file": "app/controllers/reports_controller.rb", | ||
"line": 21, | ||
"line": 25, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth keeping these ordered by line number? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is autogenerated by brakeman - I suppose we could, but it'll mean constantly fighting against the tool to do it... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given it's not really for human consumption I'd prefer to leave it. Thoughts? |
||
"link": "https://brakemanscanner.org/docs/warning_types/redirect/", | ||
"code": "redirect_to(Report.new(\"content_workflow\").url, :allow_other_host => true)", | ||
"render_path": null, | ||
|
@@ -204,6 +250,6 @@ | |
"note": "This is a redirect to AWS S3 for file download, unlikely to be dangerous." | ||
} | ||
], | ||
"updated": "2023-04-20 10:50:54 +0100", | ||
"brakeman_version": "5.4.0" | ||
"updated": "2023-09-07 15:54:38 +0100", | ||
"brakeman_version": "5.3.1" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to have
date_created
andtime_created
in theinitialize
function when we havecreated_at
(assuming we keep all 3 in thebuild_csv
method)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was explicitly requested by those who are consuming the data - the better thing to do in my mind would be to remove the
created_at
field, but I left it in there for consistency with the other reports 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be overbearingly explicit, the
column_headings
array in theinitialize
function need to match perfectly with what we create in thebuild_csv
function (as this all needs to line up properly in the right order on the csv file). So, if we add or remove something from the first array then we need to do the same in the one below, yeah? 😄