Problem/Motivation

The CrowdSec module integrates with the CrowdSec platform, which the Drupal Association partnered up with recently.

The CrowdSec module now provides a plugin manager that allows it for other modules like this to leverage this by e.g. sending a signal every time somebody fails in solving a captcha. This could then lead to a scenario where e.g. after 10 failed attempts within a configurable number of minutes, that IP would be banned on the Drupal site for a period of time, and the IP would also be signalled upstream, so that other Drupal sites could benefit from the fact, that an IP is probably brute-forcing Drupal sites.

Proposed resolution

Implement the integration.

Issue fork captcha-3552563

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jurgenhaas created an issue. See original summary.

anybody’s picture

@lrwebks can do this like in login_security :)

lrwebks’s picture

Assigned: Unassigned » lrwebks
anybody’s picture

Status: Active » Needs work

lrwebks’s picture

Assigned: lrwebks » Unassigned
Status: Needs work » Needs review

Can confirm that it works fine via monkey testing. Log messages show that CrowdSec is receiving correct signals.

anybody’s picture

Nice @lrwebks LGTM. I left a final comment. @jurgenhaas would you do the final RTBC? Then we can merge it and tag a new release. Quite a big thing with captcha.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

I'll set this RTBC for @jurgenhaas to sign it off.

jurgenhaas’s picture

RTBC+1

You may want to add the crowdsec module to require-dev in composer.json so that tests know the interfaces and methods.

anybody’s picture

Status: Reviewed & tested by the community » Needs work

Thanks @jurgenhaas! Good point!

@lrwebks could you do that please? Afterwards I'll RTBC and merge it.

lrwebks’s picture

Status: Needs work » Needs review
anybody’s picture

Looks like the require-dev entry in composer.json causes tests to fail...

anybody’s picture

Ok I think we should for now opt out from OPT_IN_TEST_NEXT_MAJOR, which also causes issues in other projects and ist not clearly something useful.

anybody’s picture

Mhm unsure, if we shouldn't better remove the

  "require-dev": {
    "drupal/crowdsec": ">=1.2.2"
  },

which are breaking the tests.

Removing OPT_IN_TEST_NEXT_MAJOR (Drupal 12) would be fine, but removing OPT_IN_TEST_PREVIOUS_MAJOR (Drupal 10) doesn't make much sense to me and makes things worse. I don't think it's worth it..

anybody’s picture

@jurgenhaas any opinions or experience with this?

Are you maybe planning to introduce

OPT_IN_TEST_NEXT_MAJOR: 1
OPT_IN_TEST_PREVIOUS_MAJOR: 1

flags for Crowdsec Module GitLab CI? Or do you think it's an antipattern?

Otherwise, I'm tending to remove the dev dependency. And I'm still not sure...

I think best might be to have these as warnings and indicator, e.g. for the next major version, not as errors maybe?

anybody changed the visibility of the branch 2.x to hidden.

jurgenhaas’s picture

Yes, I'm just working on #3578265: Get ready for Drupal 12 and should be ready for you shortly.

anybody’s picture

Whao thanks @jurgenhaas!!

jurgenhaas’s picture

@anybody this has been completed, 1.2.x-dev is ready for Drupal 12. A new release will follow as soon as we have completed the 1 remaining open issue.

anybody’s picture

anybody’s picture

Maybe we could improve .gitlab-ci.yml as follows:

include:
  ################
  # DrupalCI includes:
  # As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
  # View these include files at https://git.drupalcode.org/project/gitlab_templates/
  ################
  - project: $_GITLAB_TEMPLATES_REPO
    ref: $_GITLAB_TEMPLATES_REF
    file:
      - '/includes/include.drupalci.main.yml'
      - '/includes/include.drupalci.variables.yml'
      - '/includes/include.drupalci.workflows.yml'

################
# Pipeline configuration variables
#
# These are the variables provided to the Run Pipeline form that a user may want to override.
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
variables:
  # _PHPUNIT_CONCURRENT=1 uses run-tests.sh, 0 uses phpunit directly.
  _PHPUNIT_CONCURRENT: 1
  # Broaden test coverage.
  OPT_IN_TEST_MAX_PHP: 1
  # Convenient, and we have no secrets.
  _SHOW_ENVIRONMENT_VARIABLES: 1

# Job overrides

cspell:
  allow_failure: false

phpcs:
  allow_failure: false

phpstan:
  allow_failure: false

composer (max PHP version):
  rules:
    - when: manual
  allow_failure: true

#
# Manual builds (all other combinations)
#

## Drupal 11 (next minor)
composer-d11_next:
  stage: build
  extends: .composer-base
  variables:
    DRUPAL_CORE: "11.x-dev"
    MINIMUM_STABILITY_OVERRIDE: 'dev'
    IGNORE_PROJECT_DRUPAL_CORE_VERSION: 1
    PHP_VERSION: "8.4"
    PHP_IMAGE_VARIANT: "ubuntu-apache"
  dependencies: []
  rules:
    - when: manual
  allow_failure: true

## Drupal 10.6
composer-d10_6:
  stage: build
  extends: .composer-base
  variables:
    DRUPAL_CORE: "10.6.x"
    IGNORE_PROJECT_DRUPAL_CORE_VERSION: 1
    PHP_VERSION: "8.3"
    PHP_IMAGE_VARIANT: "ubuntu-apache"
  dependencies: []
  rules:
    - when: manual
  allow_failure: true

## Drupal 10.5
composer-d10_5:
  stage: build
  extends: .composer-base
  variables:
    DRUPAL_CORE: "10.5.x"
    IGNORE_PROJECT_DRUPAL_CORE_VERSION: 1
    PHP_VERSION: "8.2"
    PHP_IMAGE_VARIANT: "apache"
  dependencies: []
  rules:
    - when: manual
  allow_failure: true

#
# Manual validate jobs
#

phpstan-d11_next:
  extends: .phpstan-base
  stage: validate
  needs:
    - composer-d11_next
  allow_failure: true
  rules:
    - when: manual

phpstan-d10_6:
  extends: .phpstan-base
  stage: validate
  needs:
    - composer-d10_6
  allow_failure: true
  rules:
    - when: manual

#
# Manual tests
#

phpunit-d11_next:
  extends: .phpunit-base
  stage: test
  needs:
    - composer-d11_next

phpunit-d11_next-all_deprecations:
  extends: .phpunit-base
  stage: test
  needs:
    - composer-d11_next
  allow_failure: true
  rules:
    - when: manual
  variables:
    # Use core ignoreFile to show deprecations. This will only work with $_PHPUNIT_CONCURRENT=1
    SYMFONY_DEPRECATIONS_HELPER: "ignoreFile=$CI_PROJECT_DIR/$_WEB_ROOT/core/.deprecation-ignore.txt"

phpunit-d10_6:
  extends: .phpunit-base
  stage: test
  needs:
    - composer-d10_6

phpunit-d10_5:
  extends: .phpunit-base
  stage: test
  needs:
    - composer-d10_5

That's similar to what I suggested above. Found it here: #3578759: Fix GitLab pipelines (tests, phpstan, phpcs, cspell) and reduce waste

anybody’s picture

Nice! CI is finally green! @jurgenhaas could you do the final RTBC signoff? Then I'd like to merge and release this important one :)

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

LGTM

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Thank you @jurgenhaas! Merging!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.