Skip to content
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 logging of admin actions #5757

Merged
merged 15 commits into from
Nov 24, 2017
Merged

Add logging of admin actions #5757

merged 15 commits into from
Nov 24, 2017

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Nov 19, 2017

image

  • suspend account
  • silence account
  • unsuspend account
  • unsilence account
  • memorialize account
  • disable login for account
  • enable login for account
  • confirm e-mail for account
  • disable 2fa for account
  • reset password for account
  • promote account role
  • demote account role
  • disable emoji
  • enable emoji
  • dismiss report
  • create domain block
  • remove domain block
  • create e-mail domain blacklisting
  • remove e-mail domain blacklisting
  • create emoji
  • remove emoji
  • remove status
  • update status (e.g. sensitive boolean)

Notes:

  • For updates, promotes and demotes, it stores changed attributes in the log entry
  • For creates and destroys, it stores all of the record's attributes in the log entry

@Gargron Gargron added moderation Administration and moderation tooling work in progress Not to be merged, currently being worked on labels Nov 19, 2017
@Gargron Gargron self-assigned this Nov 19, 2017
@nightpool
Copy link
Member

these should show up when viewing the page for the account that an action is taken on, probably?

@joshuap
Copy link
Contributor

joshuap commented Nov 19, 2017

How to store info about record in the log after it's deleted?

We've solved this by copying the table, i.e. if the table is emoji, a duplicate deleted_emoji table would be created. The target in the admin_action_logs would then reference the DeletedEmoji model rather than Emoji. DeletedEmoji may contain a subset of attributes (e.g., only the ones needed to display the deleted record in logs).

Store some extra data e.g. from which to which role user is promoted/demoted?

For this, maybe add a metadata json/hstore column to admin_action_logs? Logfmt comes to mind, which represents logs using simple key-value pairs. User promotion would look something like:

action=promote account=admin target=@alice role=admin from_role=user

Representing logs like that can make them easier to export to other systems, too.

@Gargron
Copy link
Member Author

Gargron commented Nov 19, 2017

@joshuap I've looked up how acts_as_auditable does it - when a record is destroyed, it puts all of the records's attributes into a hstore. Although, especially with CustomEmoji, that might be kind of pointless since the image file is not stored alongside and therefore no recovery or display of that data would actually be useful.

If I don't do anything at all, the only thing I could do then is display "admin deleted CustomEmoji#345" which is kind of useless. So I think the middle ground is maybe, as you said, storing only attributes necessary for the barest minimum useful display, such as "admin deleted :cool_emoji:"

There's also acts_as_paranoid and similar approaches. I think that's gonna be useful for the statuses table, but probably not worth it for custom_emojis..? Separately from this PR, I want to make sure status deletions and account suspensions become reversible (with n days retention e.g. data is really deleted after 30 or 90 days instead of instantly)

@joshuap
Copy link
Contributor

joshuap commented Nov 20, 2017

I'm not a huge fan of default_scope in acts_as_paranoid (or in general), but I've used/contributed to the paranoia gem which does the same thing. It also has an option to skip the default_scope in case you want to use a more explicit approach when hiding deleted records.

I'm curious, how large can the statuses table grow on an instance connected to most of the federated network?

@Gargron Gargron removed the work in progress Not to be merged, currently being worked on label Nov 22, 2017
@@ -25,12 +25,15 @@ def update
def process_report
case params[:outcome].to_s
when 'resolve'
@report.update(action_taken_by_current_attributes)
@report.update!(action_taken_by_current_attributes)
log_action :dismiss, @report
Copy link
Member

@nightpool nightpool Nov 23, 2017

Choose a reason for hiding this comment

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

should probably be :resolve to match the existing terminology. (or the name of the button should be changed, which i think is probably wrong)

Copy link
Member Author

Choose a reason for hiding this comment

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

My concern is that that any action "resolves" a report. In this line, it's a resolve without any side effects like silence/suspend. It'd be weird if we had "resolves" logged for these but not for the silence/suspend versions. Therefore, I used a more clear terminology, "dismiss", i.e. "resolve without doing anything"

Copy link
Member

Choose a reason for hiding this comment

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

hmm. why aren't we logging both? I.e., suspending a user could be:

log_action :resolve, @report
log_action :suspend, @user

otherwise you'll have no idea what report a given action was taken in response to

@angristan
Copy link
Contributor

Wouldn't it be nice to have the possibility to make this page public or at least partially, allowing the users to have more transparency regarding admins/mods actions?
Just giving an idea, it's already a nice feature, so thanks for your work.

Copy link
Member

@nightpool nightpool left a comment

Choose a reason for hiding this comment

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

Changes LGTM, but they should probably also include a Site Settings log type, right? I couldn't find logging for that anywhere.

@Gargron
Copy link
Member Author

Gargron commented Nov 23, 2017

The commit history of this PR is an awful mess because I wasn't able to rebase due to PRs made against this PR. :(

Copy link
Contributor

@nullkal nullkal left a comment

Choose a reason for hiding this comment

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

We need to run i18n-tasks normalize.

@Gargron Gargron merged commit e84fecb into master Nov 24, 2017
@Gargron Gargron deleted the feature-mod-accountability branch November 24, 2017 01:05
@Gargron Gargron mentioned this pull request Nov 27, 2017
10 tasks
ykzts pushed a commit that referenced this pull request Dec 5, 2017
* i18n: (zh-CN) Add missing translations for multiple PRs.
Related PRs: #5838 #5762 #5835 #5837 #5832 #5823 #5814 #5757

* i18n: (zh-CN) Fix translation for #5823 / #5835

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Change `发送者` to `作者`

* i18n: (zh-CN) Add missing translations for #5862

* i18n: (zh-CN) Add missing translation for #5874

* i18n: (zh-CN) Improve translations for keyboard shortcuts
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017
* Add logging of admin actions

* Update brakeman whitelist

* Log creates, updates and destroys with history of changes

* i18n: Update Polish translation (mastodon#5782)

Signed-off-by: Marcin Mikołajczak <me@m4sk.in>

* Split admin navigation into moderation and administration

* Redesign audit log page

* 🇵🇱 (mastodon#5795)

* Add color coding to audit log

* Change dismiss->resolve, log all outcomes of report as resolve

* Update terminology (e-mail blacklist) (mastodon#5796)

* Update terminology (e-mail blacklist)

imho looks better

* Update en.yml

* Fix code style issues

* i18n-tasks normalize
cobodo pushed a commit to cobodo/mastodon that referenced this pull request Dec 6, 2017
…on#5849)

* i18n: (zh-CN) Add missing translations for multiple PRs.
Related PRs: mastodon#5838 mastodon#5762 mastodon#5835 mastodon#5837 mastodon#5832 mastodon#5823 mastodon#5814 mastodon#5757

* i18n: (zh-CN) Fix translation for mastodon#5823 / mastodon#5835

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Improve translations

* i18n: (zh-CN) Change `发送者` to `作者`

* i18n: (zh-CN) Add missing translations for mastodon#5862

* i18n: (zh-CN) Add missing translation for mastodon#5874

* i18n: (zh-CN) Improve translations for keyboard shortcuts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moderation Administration and moderation tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants