HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Note Permission
    • Read
      • Owners
      • Signed-in users
      • Everyone
      Owners Signed-in users Everyone
    • Write
      • Owners
      • Signed-in users
      • Everyone
      Owners Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions
    • Transfer ownership
    • Delete this note
    • Template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- tags: cofacts --- # Cofacts spam removal automation > Initially proposed: > https://g0v.hackmd.io/uefTz4yURImgtem--itaMw?both#Op-%E5%9E%83%E5%9C%BE%E8%A8%8A%E6%81%AF%E5%8F%8D%E5%88%B6 ## Purpose We should be able to deal with simple spam more easily. - No SSH access needed - More people can approve and run takedowns - Approvals are logged and openly accessible When a spammer comes to Cofacts to post spam, we should be able to: 1. Automatically detect such spam. 2. Automatically generate announcement for both automatically detected and manually reported spam. 3. Approve announcement and command to execute on Github; can require just one approval, and give permission to more people. 4. Can execute the command on the approved and merged PR, with no SSH needed. ## Phases and changes It is easier if we implement "backwards" -- start with command automation first, then the Github approval part, and put the automatic detection in the last phase. ### Phase 1: Script execution automation :::spoiler Legacy design: Google Pub/sub > This design is abandoned in favor of Cloudflare Zero Trust managed APIs. > See https://g0v.hackmd.io/_e0nyj04SoCzxdM38CzuYQ#Op-%E5%A4%96%E9%83%A8%E6%95%B4%E5%90%88%EF%BC%9AAdmin-API for reason Target: Can execute block user script (or any other scripts) on Google cloud console. The UI that submits message ![](https://s3-ap-northeast-1.amazonaws.com/g0v-hackmd-images/uploads/upload_b338a25ef556f910b1f533f57b93c8f6.png) #### API - A service that runs along with API server - Subscribes to pubsub - Calls scripts as functions #### Google Pubsub - Create a pubsub topic just for scripts - Design message schema - Include script name to execute + arguments - Executes script on google cloud console ::: A new OpenAPI server is spinned up to host admin APIs. - its implementation exists alongside with rumors-api, so that the admin APIs can leverage scripts and util functions in rumors-api - The APIs are not exposed via nginx; instead, they map to certain domains using Cloudflare Tunnels - `dev-admin-api.cofacts.tw` --> `cofacts-api-staging:5500` - `admin-api.cofacts.tw` --> `api:5500` #### API Implement the following endpoint using feTS & OpenAPI. The path hierarchy is designed for easier management using Cloudflare. - `/moderation` series: designed for Cofacts automations, including - POST `/moderation/blockedUser`: block a user (or update block info). Map to current `blockUser` script. - POST `/moderation/article/media`: replace the media of an article. Map to current `replaceMedia` script. - POST `/moderation/aiReply`: regenerate AI reply. Map to current `genAIReply` script. - `/badge` series: reserved for Badge operations (TBA) - Others: feTS provides `/docs` for Swagger UI, and `/openapi.json` for OpenAPI spec file. We log all access to the API to console. Fields to be included: - The invoked endpoint - `user` - who initiated the request. Can be: - email, when [identity-based authentication](https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/application-token/#identity-based-authentication) is used - [Client ID of the service token](https://developers.cloudflare.com/cloudflare-one/identity/authorization-cookie/application-token/#service-token-authentication) - request payload #### Cloudflare Zero Trust ##### Tunnels `admin-api.cofacts.tw`: production site rumors-admin-api `dev-admin-api.cofacts.tw`: staging site rumors-admin-api ##### Applications > When multiple rules are set for a common root path, the more specific rule takes precedence. For example, when setting rules for `dashboard.com/eng` and `dashboard.com/eng/exec` separately, the more specific rule for `dashboard.com/eng/exec` takes precedence, and no rule is inherited from `dashboard.com/eng`. If no separate, specific rule is set for `dashboard.com/eng/exec`, it will inherit any rules set for `dashboard.com/eng`. > > [name=[Cloudflare documentation](https://developers.cloudflare.com/cloudflare-one/policies/access/app-paths/#policy-inheritance)] General rule: `(dev-)admin-api.cofacts.tw`: Allow all users & any service tokens - Any emails within specific access groups can access after login - They can access `/docs` to read documentation - Emails not in whitelist can't even receive login codes - Can use any service token to get `/openapi.json` to generate types, etc More specific rules: - `(dev-)admin-api.cofacts.tw/badge`: Only allow badge manager and Cofacts WG email logins & service tokens - `(dev-)admin-api.cofacts.tw/moderation`: Only allow Cofacts WG email logins & service tokens Email logins are included in the policy so that they work in Swagger UI. ##### Access groups - Cofacts WG email logins: emails ending with `@cofacts.tw` - Cofacts WG service tokens - Badge manager email logins: emails ending in TFC and specific white lists - Badge manager service tokens ### Phase 2: Command template in PR template #### Command template > - API: `/path/to/invoke` > - Body: > ```json > {...} > ``` #### Takedowns Github action - On PR creation & edit, if the pull request description includes the pattern above, check the API and its body. - On PR merge, if the pull request description includes the pattern above, call the API with specified body with Cofacts WG service tokens. ### Phase 3: Automatic detection #### GitHub action - Use GitHub app to create a takedown pull request, if LLM recognize a reply as second scam(二次詐騙) or sexual content - Schduled query reply after `LAST_SCANNED_AT` - Filtered out known users that existed in pervious pr by parsing the pr title - List the 10 more replies written by the suspicious user for the moderator to review and determine if they are a spammer. :::spoiler Outdated design #### Google Pubsub - Create a new Pubsub topic for Cofacts' object creation - Define schema: object type + inserted doc #### API - Publish event on Mutation APIs - for creation of reply, article, etc #### Google cloudrun/cloud function (?) - Subscribe to the topic & calls cloudrun / cloud function. - Consume pubsub topics, detect spam and make Github pull requests when necessary. :::

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

Sign in via GitHub

New to HackMD? Sign up

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions

Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.