Skip to content

Commit

Permalink
Make the list of banned users configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffiscow2 authored and abompard committed Dec 9, 2024
1 parent 771b7b3 commit 0a7f114
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 35 deletions.
31 changes: 31 additions & 0 deletions devel/ansible/roles/dev/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,37 @@ distgit_hostname = "src.tinystage.test"
id_provider_hostname = "id.tinystage.test"
fasjson_base_url = "https://fasjson.tinystage.test/fasjson"

# Users skipped when awarding badges
skip_users = [
"bodhi",
"oscar",
"apache",
"koji",
"bodhi",
"taskotron",
"pagure",
"packit",
"packit-stg",
"koschei",
"distrobuildsync-eln/jenkins-continuous-infra.apps.ci.centos.org",
"root",
"zodbot",
"bodhidev-bot",
"eclipse-bluechi-bot",
"githubbotargparsemanpage",
"imagebuilder-bot",
"knet-ci-bot",
"l10nbot",
"noobdevbot",
"notifs-bot",
"notifs-stg-bot",
"osbuild-automation-bot",
"releng-bot",
"sambabot",
"sourcegraph-bot",
"theforeman-bot",
"rhcontainerbot",
]

# Cache configuation
[consumer_config.cache]
Expand Down
32 changes: 32 additions & 0 deletions fedbadges.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ fasjson_base_url = "https://fasjson.fedoraproject.org"
# Check for new rules every these many minutes
rules_reload_interval = 15

# Users skipped when awarding badges
skip_users = [
"bodhi",
"oscar",
"apache",
"koji",
"bodhi",
"taskotron",
"pagure",
"packit",
"packit-stg",
"koschei",
"distrobuildsync-eln/jenkins-continuous-infra.apps.ci.centos.org",
"root",
"zodbot",
"bodhidev-bot",
"eclipse-bluechi-bot",
"githubbotargparsemanpage",
"imagebuilder-bot",
"knet-ci-bot",
"l10nbot",
"noobdevbot",
"notifs-bot",
"notifs-stg-bot",
"osbuild-automation-bot",
"releng-bot",
"sambabot",
"sourcegraph-bot",
"theforeman-bot",
"rhcontainerbot",
]

# Cache configuation
[consumer_config.cache]
backend = "dogpile.cache.memory"
Expand Down
37 changes: 2 additions & 35 deletions fedbadges/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,39 +93,6 @@ class BadgeRule:
]
)

banned_usernames = frozenset(
[
"bodhi",
"oscar",
"apache",
"koji",
"bodhi",
"taskotron",
"pagure",
"packit",
"packit-stg",
"koschei",
"distrobuildsync-eln/jenkins-continuous-infra.apps.ci.centos.org",
"root",
"zodbot",
"bodhidev-bot",
"eclipse-bluechi-bot",
"githubbotargparsemanpage",
"imagebuilder-bot",
"knet-ci-bot",
"l10nbot",
"noobdevbot",
"notifs-bot",
"notifs-stg-bot",
"osbuild-automation-bot",
"releng-bot",
"sambabot",
"sourcegraph-bot",
"theforeman-bot",
"rhcontainerbot",
]
)

def __init__(self, badge_dict, issuer_id, config, fasjson):
try:
validate_fields(self.required, self.possible, badge_dict)
Expand Down Expand Up @@ -222,8 +189,8 @@ def _get_candidates(self, msg: Message, tahrir: TahrirDatabase):
# Remove None
candidates = frozenset([e for e in candidates if e is not None])

# Exclude banned usernames
candidates = candidates.difference(self.banned_usernames)
# Skipped usernames
candidates = candidates.difference(frozenset(self.config.get("skip_users", [])))

# Strip anyone who is an IP address
candidates = frozenset(
Expand Down

0 comments on commit 0a7f114

Please sign in to comment.