nock / nock

HTTP server mocking and expectations library for Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Disabled discussions

Uzlopak opened this issue · comments

Please avoid duplicates

Reproducible test case

Nock Version

Node Version

TypeScript Version

What happened?

@gr2m

A malicious user cufret02 was spamming the repo discussions. I tried to delete some via mobile phone but it was too much. The attack started 6:45 and i stopped it at 7:36 am german time. Maybe this is an attack hidden behind a spam attack, as it resulted in being spammed via email.

Would you be interested in contributing a fix?

  • yes

Thanks!

Maybe we can just ban them? In the same way they can open a lot of issues.

@mikicho

I dont see the option to do it. Maybe @gr2m or so has more permissions than I, and can ban this user.

Thank you @Uzlopak for taking care of it. You should now have both access to the org moderation tools such as https://github.com/organizations/nock/settings/blocked_users

What should be able to do is to report the user for spamming, if enough people do so in a short amount of time, their account gets blocked.

best moderation tool in case of attacks like this is to limit interaction to existing users:
https://github.com/organizations/nock/settings/interaction_limits

I'll delete all the non-sense discussions

For the record, here is the script I used

const { Octokit } = require("octokit");

const USER_LOGIN = "cufret02"

const octokit = new Octokit({
  auth: process.env.GITHUB_TOKEN,
});

main();

async function main() {
  // get all discussions
  const result = await octokit.graphql(
    `
    query paginate($cursor: String) {
      repository(owner: "nock", name: "nock") {
        discussions(first: 100, after: $cursor) {
          nodes {
            id
            title
            url
            author {
              login
            }
          }
          pageInfo {
            hasNextPage
            endCursor
          }
        }
      }
    }`
  );

  const discussions = result.repository.discussions.nodes;
  for (const discussion of discussions) {
    if (discussion.author.login !== USER_LOGIN) continue;

    // delete discussion
    await octokit.graphql(
      `
      mutation deleteDiscussion($id: ID!) {
        deleteDiscussion(input: { id: $id }) {
          clientMutationId
        }
      }`,
      {
        id: discussion.id,
      }
    );
    console.log("discussion %s deleted", discussion.title);
  }
}