#1960 Avoid using "blacklist" word
Merged 2 years ago by praiskup. Opened 2 years ago by praiskup.
Unknown source denylist  into  main

@@ -104,7 +104,7 @@

  STORAGE_DIR = "/var/lib/copr/data/srpm_storage"

  

  # no need to filter cla_* groups, they are already filtered by fedora openid

- BLACKLISTED_GROUPS = ['fedorabugs', 'packager', 'provenpackager']

+ GROUP_DENYLIST = ['fedorabugs', 'packager', 'provenpackager']

  

  REDIS_HOST = "redis"

  REDIS_PORT = 6379

@@ -0,0 +1,20 @@

+ """

+ blacklist => denylist

+ 

+ Revision ID: 33a73ed44f83

+ Revises: b630bad8a01e

+ Create Date: 2021-10-20 21:16:15.229677

+ """

+ 

+ from alembic import op

+ 

+ revision = '33a73ed44f83'

+ down_revision = 'b630bad8a01e'

+ 

+ def upgrade():

+     op.alter_column('package', 'chroot_blacklist_raw',

+                     new_column_name='chroot_denylist_raw')

+ 

+ def downgrade():

+     op.alter_column('package', 'chroot_denylist_raw',

+                     new_column_name='chroot_blacklist_raw')

@@ -107,7 +107,7 @@

  STORAGE_DIR = "/var/lib/copr/data/srpm_storage"

  

  # no need to filter cla_* groups, they are already filtered by fedora openid

- BLACKLISTED_GROUPS = ['fedorabugs', 'packager', 'provenpackager']

+ GROUP_DENYLIST = ['fedorabugs', 'packager', 'provenpackager']

  

  REDIS_HOST = "127.0.0.1"

  REDIS_PORT = 6379

@@ -59,7 +59,7 @@

  STORAGE_DIR = "/var/lib/copr/data/srpm_storage"

  

  # no need to filter cla_* groups, they are already filtered by fedora openid

- BLACKLISTED_GROUPS = ['fedorabugs', 'packager', 'provenpackager']

+ GROUP_DENYLIST = ['fedorabugs', 'packager', 'provenpackager']

  

  # Hide page parts not relevant to this Copr instance:

  # LAYOUT_OVERVIEW_HIDE_QUICK_ENABLE = False

@@ -743,33 +743,37 @@

          return form

  

  

- def cleanup_chroot_blacklist(string):

+ def cleanup_chroot_denylist(string):

+     """ Filter invalid values out from BasePackageForm.chroot_denylist field """

+ 

      if not string:

          return string

      fields = [x.lstrip().rstrip() for x in string.split(',')]

      return ', '.join(fields)

  

  

- def validate_chroot_blacklist(form, field):

+ def validate_chroot_denylist(_form, field):

+     """ Validate BasePackageForm.chroot_denylist field """

+ 

      if field.data:

          string = field.data

-         fields = [x.lstrip().rstrip() for x in string.split(',')]

-         for field in fields:

+         items = [x.lstrip().rstrip() for x in string.split(',')]

+         for item in items:

              pattern = r'^[a-z0-9-_*]+$'

-             if not re.match(pattern, field):

-                 raise wtforms.ValidationError('Pattern "{0}" does not match "{1}"'.format(field, pattern))

+             if not re.match(pattern, item):

+                 raise wtforms.ValidationError('Pattern "{0}" does not match "{1}"'.format(item, pattern))

  

              matched = set()

              all_chroots = MockChrootsLogic.active_names()

              for chroot in all_chroots:

-                 if fnmatch(chroot, field):

+                 if fnmatch(chroot, item):

                      matched.add(chroot)

  

              if not matched:

-                 raise wtforms.ValidationError('no chroot matched by pattern "{0}"'.format(field))

+                 raise wtforms.ValidationError('no chroot matched by pattern "{0}"'.format(item))

  

              if matched == all_chroots:

-                 raise wtforms.ValidationError('patterns are black-listing all chroots')

+                 raise wtforms.ValidationError('patterns are deny-listing all chroots')

  

  

  class BasePackageForm(FlaskForm):
@@ -785,12 +789,12 @@

      )

  

      webhook_rebuild = wtforms.BooleanField(default=False, false_values=FALSE_VALUES)

-     chroot_blacklist = wtforms.StringField(

-         "Chroot blacklist",

-         filters=[cleanup_chroot_blacklist],

+     chroot_denylist = wtforms.StringField(

+         "Chroot denylist",

+         filters=[cleanup_chroot_denylist],

          validators=[

              wtforms.validators.Optional(),

-             validate_chroot_blacklist,

+             validate_chroot_denylist,

          ],

      )

      max_builds = wtforms.IntegerField(

@@ -92,21 +92,23 @@

          return group

  

      @classmethod

-     def filter_blacklisted_teams(cls, teams):

-         """ removes blacklisted groups from teams list

+     def filter_denylisted_teams(cls, teams):

+         """ removes denylisted groups from teams list

              :type teams: list of str

              :return: filtered teams

              :rtype: list of str

          """

-         blacklist = set(app.config.get("BLACKLISTED_GROUPS", []))

-         return filter(lambda t: t not in blacklist, teams)

+         denylist = set(app.config.get("GROUP_DENYLIST", []))

+         return filter(lambda t: t not in denylist, teams)

  

      @classmethod

-     def is_blacklisted_group(cls, fas_group):

-         if "BLACKLISTED_GROUPS" in app.config:

-             return fas_group in app.config["BLACKLISTED_GROUPS"]

-         else:

-             return False

+     def is_denylisted_group(cls, fas_group):

+         """

+         Return true if FAS_GROUP is on GROUP_DENYLIST in copr configuration.

+         """

+         if "GROUP_DENYLIST" in app.config:

+             return fas_group in app.config["GROUP_DENYLIST"]

+         return False

  

      @classmethod

      def delete_user_data(cls, user):

@@ -825,7 +825,7 @@

  

      # comma-separated list of wildcards of chroot names that this package should

      # not be built against, e.g. "fedora-*, epel-*-i386"

-     chroot_blacklist_raw = db.Column(db.Text)

+     chroot_denylist_raw = db.Column(db.Text)

  

      @property

      def dist_git_repo(self):
@@ -888,18 +888,22 @@

  

  

      @property

-     def chroot_blacklist(self):

-         if not self.chroot_blacklist_raw:

+     def chroot_denylist(self):

+         """

+         Parse the raw field 'chroot_denylist_raw' and return the list of

+         wildcard patterns to match self.active_chroots against.

+         """

+         if not self.chroot_denylist_raw:

              return []

  

-         blacklisted = []

-         for pattern in self.chroot_blacklist_raw.split(','):

+         denylisted = []

+         for pattern in self.chroot_denylist_raw.split(','):

              pattern = pattern.strip()

              if not pattern:

                  continue

-             blacklisted.append(pattern)

+             denylisted.append(pattern)

  

-         return blacklisted

+         return denylisted

  

  

      @staticmethod
@@ -925,13 +929,13 @@

      @property

      def chroots(self):

          chroots = list(self.copr.active_chroots)

-         if not self.chroot_blacklist_raw:

-             # no specific blacklist

+         if not self.chroot_denylist_raw:

+             # no specific denylist

              if self.copr_dir.main:

                  return chroots

              return self.main_pkg.chroots

  

-         filtered = [c for c in chroots if not self.matched_chroot(c, self.chroot_blacklist)]

+         filtered = [c for c in chroots if not self.matched_chroot(c, self.chroot_denylist)]

          # We never want to filter everything, this is a misconfiguration.

          return filtered if filtered else chroots

  

@@ -58,7 +58,7 @@

        <h3 class="panel-title">{{ counter('instructions') }}. Generic package setup</h3>

      </div>

      <div class="panel-body">

- {{ render_field(form.chroot_blacklist,

+ {{ render_field(form.chroot_denylist,

                  placeholder="Optional - comma-separated list of wildcard-patterns, e.g.  fedora-*, *-i386",

                  info="What chroots should be skipped for this package, by default we build for all.",

  )}}

@@ -56,9 +56,9 @@

            <dd>{{ package.max_builds }}</dd>

            {% endif %}

  

-           {% if package.chroot_blacklist_raw %}

+           {% if package.chroot_denylist_raw %}

            <dt>Excluded chroots:</dt>

-           <dd>{{ package.chroot_blacklist_raw }}</dd>

+           <dd>{{ package.chroot_denylist_raw }}</dd>

            {% endif %}

  

            {% if package.chroots | length != package.copr.active_chroots | list | length %}

@@ -194,7 +194,7 @@

      package = ComplexLogic.get_package_safe(copr.main_dir, package_name)

      data = package.source_json_dict

      data["webhook_rebuild"] = package.webhook_rebuild

-     data["chroot_blacklist"] = package.chroot_blacklist_raw

+     data["chroot_denylist"] = package.chroot_denylist_raw

      data["max_builds"] = package.max_builds

  

      if package.has_source_type_set and not source_type_text:
@@ -268,7 +268,7 @@

              package.source_type = helpers.BuildSourceEnum(source_type_text)

              package.webhook_rebuild = form.webhook_rebuild.data

              package.source_json = form.source_json

-             package.chroot_blacklist_raw = form.chroot_blacklist.data

+             package.chroot_denylist_raw = form.chroot_denylist.data

              package.max_builds = form.max_builds.data

  

              db.session.add(package)

@@ -24,8 +24,8 @@

      form = ActivateFasGroupForm()

  

      if form.validate_on_submit():

-         if UsersLogic.is_blacklisted_group(fas_group):

-             flask.flash("This group is blacklisted and cannot be added.")

+         if UsersLogic.is_denylisted_group(fas_group):

+             flask.flash("This group is denylisted and cannot be added.")

              return flask.redirect(url_for(

                  "groups_ns.list_user_groups"))

  
@@ -94,7 +94,7 @@

          UsersLogic.get_groups_by_fas_names_list(teams).all()

      }

  

-     teams = list(UsersLogic.filter_blacklisted_teams(teams))

+     teams = list(UsersLogic.filter_denylisted_teams(teams))

  

      copr_groups = {

          fas_name: active_map.get(fas_name)

@@ -25,25 +25,29 @@

          assert expected_1 == result_1

  

  

-     def test_chroot_blacklist(self, f_users, f_coprs, f_builds, f_mock_chroots_many, f_pr_dir, f_db):

+     @pytest.mark.usefixtures("f_users", "f_coprs", "f_builds",

+                              "f_mock_chroots_many", "f_pr_dir", "f_db")

+     def test_chroot_denylist(self):

          # test main package

          assert len(list(self.p1.chroots)) == 15

-         self.p1.chroot_blacklist_raw = '*-19-*, epel*'

-         assert len(self.p1.chroot_blacklist) == 2

+         self.p1.chroot_denylist_raw = '*-19-*, epel*'

+         assert len(self.p1.chroot_denylist) == 2

          assert len(list(self.p1.chroots)) == 8

  

          # non-main package inherits from main package by default

          assert len(list(self.p4.chroots)) == 8

  

-         # but if we set the blacklist here, too, it get's precedence

-         self.p4.chroot_blacklist_raw = 'epel*'

-         assert len(self.p4.chroot_blacklist) == 1

+         # but if we set the denylist here, too, it get's precedence

+         self.p4.chroot_denylist_raw = 'epel*'

+         assert len(self.p4.chroot_denylist) == 1

          assert len(list(self.p4.chroots)) == 10

  

-     def test_chroot_blacklist_all(self, f_users, f_coprs, f_builds, f_mock_chroots_many, f_pr_dir, f_db):

+     @pytest.mark.usefixtures("f_users", "f_coprs", "f_builds",

+                              "f_mock_chroots_many", "f_pr_dir", "f_db")

+     def test_chroot_denylist_all(self):

          assert len(list(self.p1.chroots)) == 15

          assert len(list(self.p1.copr.active_chroots)) == 15

-         self.p1.chroot_blacklist_raw = '*'

+         self.p1.chroot_denylist_raw = '*'

          # even though we blacklised (by mistake) all chroots, package builds

          # against all chroots (fallback)

          assert len(list(self.p1.chroots)) == 15

no initial comment

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

3 new commits added

  • frontend: fix PyLint issues related to #1960
  • frontend: conscious language (group blacklist -> denylist)
  • frontend: conscious language (chroot blacklist -> denylist)
2 years ago

Build succeeded.

Can you also fix BLACKLISTED_GROUPS in copr.conf for docker, please?
Otherwise, +1.

3 new commits added

  • frontend: fix PyLint issues related to #1960
  • frontend: conscious language (group blacklist -> denylist)
  • frontend: conscious language (chroot blacklist -> denylist)
2 years ago

rebased onto 5157485

2 years ago

Build succeeded.

Commit 37e981e fixes this pull-request

Pull-Request has been merged by praiskup

2 years ago

Pull-Request has been merged by praiskup

2 years ago