Compare commits
42 Commits
Author | SHA1 | Date |
---|---|---|
github-actions | e83099413b | |
github-actions | 7630307964 | |
Guy Sartorelli | ba9f5d868a | |
Guy Sartorelli | 77aba75ffa | |
Guy Sartorelli | a5b2363e35 | |
Guy Sartorelli | 3079188625 | |
Will Rossiter | 6f85c7e5ba | |
Will Rossiter | 9d368b556f | |
Will Rossiter | fa8366e706 | |
Will Rossiter | 6d2ec29d32 | |
Will Rossiter | d10b6a1671 | |
Guy Sartorelli | 221089136f | |
Will Rossiter | 17106d8f30 | |
Guy Sartorelli | 2d59501ef3 | |
Guy Sartorelli | 0879af9c99 | |
Steve Boyd | a0ae7ef940 | |
github-actions | 7e1b433384 | |
github-actions | ac5f27d0b9 | |
Guy Sartorelli | a88640849e | |
Steve Boyd | 4f75f5253c | |
Guy Sartorelli | de3129fa92 | |
Bernard Hamlin | a3586210e2 | |
Steve Boyd | 03eb0d42b9 | |
Steve Boyd | 4b3f5a2599 | |
Guy Sartorelli | 5cecb82116 | |
Steve Boyd | e08ac10658 | |
Steve Boyd | 9ab49fadb6 | |
Guy Sartorelli | e1b4ea2807 | |
Sabina Talipova | c08ec451bf | |
Guy Sartorelli | 00869b6755 | |
Steve Boyd | 8efc022acd | |
Steve Boyd | cfcfa9352c | |
Steve Boyd | 5254e92d52 | |
Steve Boyd | 9e74d2749e | |
Steve Boyd | 04f6d63258 | |
Maxime Rainville | 41cd3190ee | |
Steve Boyd | 20270caef8 | |
Sabina Talipova | ad2dd60c77 | |
Steve Boyd | f194344efe | |
Sabina Talipova | 537b1b9290 | |
Maxime Rainville | d4df0bad4c | |
Sabina Talipova | d669b42cc9 |
|
@ -0,0 +1 @@
|
|||
<!-- Blank templates are for use by maintainers only! If you aren't a maintainer, please go back and pick one of the issue templates. -->
|
|
@ -0,0 +1,72 @@
|
|||
name: 🪳 Bug Report
|
||||
description: Tell us if something isn't working the way it's supposed to
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
We strongly encourage you to [submit a pull request](https://docs.silverstripe.org/en/contributing/code/) which fixes the issue.
|
||||
Bug reports which are accompanied with a pull request are a lot more likely to be resolved quickly.
|
||||
- type: input
|
||||
id: affected-versions
|
||||
attributes:
|
||||
label: Module version(s) affected
|
||||
description: |
|
||||
What version of _this module_ have you reproduced this bug on?
|
||||
Run `composer info` to see the specific version of each module installed in your project.
|
||||
If you don't have access to that, check inside the help menu in the bottom left of the CMS.
|
||||
placeholder: x.y.z
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: A clear and concise description of the problem
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: how-to-reproduce
|
||||
attributes:
|
||||
label: How to reproduce
|
||||
description: |
|
||||
⚠️ This is the most important part of the report ⚠️
|
||||
Without a way to easily reproduce your issue, there is little chance we will be able to help you and work on a fix.
|
||||
- Please, take the time to show us some code and/or configuration that is needed for others to reproduce the problem easily.
|
||||
- If the bug is too complex to reproduce with some short code samples, please reproduce it in a public repository and provide a link to the repository along with steps for setting up and reproducing the bug using that repository.
|
||||
- If part of the bug includes an error or exception, please provide a full stack trace.
|
||||
- If any user interaction is required to reproduce the bug, please add an ordered list of steps that are required to reproduce it.
|
||||
- Be as clear as you can, but don't miss any steps out. Simply saying "create a page" is less useful than guiding us through the steps you're taking to create a page, for example.
|
||||
placeholder: |
|
||||
|
||||
#### Code sample
|
||||
```php
|
||||
|
||||
```
|
||||
|
||||
#### Reproduction steps
|
||||
1.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: possible-solution
|
||||
attributes:
|
||||
label: Possible Solution
|
||||
description: |
|
||||
*Optional: only if you have suggestions on a fix/reason for the bug*
|
||||
Please consider [submitting a pull request](https://docs.silverstripe.org/en/contributing/code/) with your solution! It helps get faster feedback and greatly increases the chance of the bug being fixed.
|
||||
- type: textarea
|
||||
id: additional-context
|
||||
attributes:
|
||||
label: Additional Context
|
||||
description: "*Optional: any other context about the problem: log messages, screenshots, etc.*"
|
||||
- type: checkboxes
|
||||
id: validations
|
||||
attributes:
|
||||
label: Validations
|
||||
description: "Before submitting the issue, please make sure you do the following:"
|
||||
options:
|
||||
- label: Check that there isn't already an issue that reports the same bug
|
||||
required: true
|
||||
- label: Double check that your reproduction steps work in a fresh installation of [`silverstripe/installer`](https://github.com/silverstripe/silverstripe-installer) (with any code examples you've provided)
|
||||
required: true
|
|
@ -0,0 +1,35 @@
|
|||
name: 🚀 Feature Request
|
||||
description: Submit a feature request (but only if you're planning on implementing it)
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Please only submit feature requests if you plan on implementing the feature yourself.
|
||||
See the [contributing code documentation](https://docs.silverstripe.org/en/contributing/code/#make-or-find-a-github-issue) for more guidelines about submitting feature requests.
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: A clear and concise description of the new feature, and why it belongs in core
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: more-info
|
||||
attributes:
|
||||
label: Additional context or points of discussion
|
||||
description: |
|
||||
*Optional: Any additional context, points of discussion, etc that might help validate and refine your idea*
|
||||
- type: checkboxes
|
||||
id: validations
|
||||
attributes:
|
||||
label: Validations
|
||||
description: "Before submitting the issue, please confirm the following:"
|
||||
options:
|
||||
- label: You intend to implement the feature yourself
|
||||
required: true
|
||||
- label: You have read the [contributing guide](https://docs.silverstripe.org/en/contributing/code/)
|
||||
required: true
|
||||
- label: You strongly believe this feature should be in core, rather than being its own community module
|
||||
required: true
|
||||
- label: You have checked for existing issues or pull requests related to this feature (and didn't find any)
|
||||
required: true
|
|
@ -0,0 +1,8 @@
|
|||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Security Vulnerability
|
||||
url: https://docs.silverstripe.org/en/contributing/issues_and_bugs/#reporting-security-issues
|
||||
about: ⚠️ We do not use GitHub issues to track security vulnerability reports. Click "open" on the right to see how to report security vulnerabilities.
|
||||
- name: Support Question
|
||||
url: https://www.silverstripe.org/community/
|
||||
about: We use GitHub issues only to discuss bugs and new features. For support questions, please use one of the support options available in our community channels.
|
|
@ -0,0 +1,39 @@
|
|||
<!--
|
||||
Thanks for contributing, you're awesome! ⭐
|
||||
|
||||
Please read https://docs.silverstripe.org/en/contributing/code/ if you haven't contributed to this project recently.
|
||||
-->
|
||||
## Description
|
||||
<!--
|
||||
Please describe expected and observed behaviour, and what you're fixing.
|
||||
For visual fixes, please include tested browsers and screenshots.
|
||||
-->
|
||||
|
||||
## Manual testing steps
|
||||
<!--
|
||||
Include any manual testing steps here which a reviewer can perform to validate your pull request works correctly.
|
||||
Note that this DOES NOT replace unit or end-to-end tests.
|
||||
-->
|
||||
|
||||
## Issues
|
||||
<!--
|
||||
List all issues here that this pull request fixes/resolves.
|
||||
If there is no issue already, create a new one! You must link your pull request to at least one issue.
|
||||
-->
|
||||
- #
|
||||
|
||||
## Pull request checklist
|
||||
<!--
|
||||
PLEASE check each of these to ensure you have done everything you need to do!
|
||||
If there's something in this list you need help with, please ask so that we can assist you.
|
||||
-->
|
||||
- [ ] The target branch is correct
|
||||
- See [picking the right version](https://docs.silverstripe.org/en/contributing/code/#picking-the-right-version)
|
||||
- [ ] All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
|
||||
- Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
|
||||
- [ ] The commit messages follow our [commit message guidelines](https://docs.silverstripe.org/en/contributing/code/#commit-messages)
|
||||
- [ ] The PR follows our [contribution guidelines](https://docs.silverstripe.org/en/contributing/code/)
|
||||
- [ ] Code changes follow our [coding conventions](https://docs.silverstripe.org/en/contributing/coding_conventions/)
|
||||
- [ ] This change is covered with tests (or tests aren't necessary for this change)
|
||||
- [ ] Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
|
||||
- [ ] CI is green
|
|
@ -1,10 +1,10 @@
|
|||
name: Keepalive
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
# The 4th of every month at 10:50am UTC
|
||||
# At 8:40 AM UTC, on day 9 of the month
|
||||
schedule:
|
||||
- cron: '50 10 4 * *'
|
||||
- cron: '40 8 9 * *'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
keepalive:
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
name: Merge-up
|
||||
|
||||
on:
|
||||
# At 11:10 AM UTC, only on Wednesday
|
||||
schedule:
|
||||
- cron: '10 11 * * 3'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
merge-up:
|
||||
name: Merge-up
|
||||
# Only run cron on the silverstripe account
|
||||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Merge-up
|
||||
uses: silverstripe/gha-merge-up@v1
|
11
.upgrade.yml
11
.upgrade.yml
|
@ -1,11 +0,0 @@
|
|||
mappings:
|
||||
SpamProtector: SilverStripe\SpamProtection\SpamProtector
|
||||
CommentSpamProtection: SilverStripe\SpamProtection\Extension\CommentSpamProtection
|
||||
EditableSpamProtectionField: SilverStripe\SpamProtection\EditableSpamProtectionField
|
||||
FormSpamProtectionExtension: SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension
|
||||
EditableSpamProtectionFieldTest: SilverStripe\SpamProtection\Tests\EditableSpamProtectionFieldTest
|
||||
EditableSpamProtectionFieldTest_Protector: SilverStripe\SpamProtection\Tests\Stub\Protector
|
||||
FormSpamProtectionExtensionTest: SilverStripe\SpamProtection\Tests\FormSpamProtectionExtensionTest
|
||||
FormSpamProtectionExtensionTest_BarProtector: SilverStripe\SpamProtection\Tests\Stub\BarProtector
|
||||
FormSpamProtectionExtensionTest_BazProtector: SilverStripe\SpamProtection\Tests\Stub\BazProtector
|
||||
FormSpamProtectionExtensionTest_FooProtector: SilverStripe\SpamProtection\Tests\Stub\FooProtector
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017, SilverStripe Limited
|
||||
Copyright (c) 2017, Silverstripe Limited
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
17
README.md
17
README.md
|
@ -3,6 +3,12 @@
|
|||
[![CI](https://github.com/silverstripe/silverstripe-spamprotection/actions/workflows/ci.yml/badge.svg)](https://github.com/silverstripe/silverstripe-spamprotection/actions/workflows/ci.yml)
|
||||
[![Silverstripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
composer require silverstripe/spamprotection
|
||||
```
|
||||
|
||||
## Maintainer Contact
|
||||
|
||||
* Saophalkun Ponlu
|
||||
|
@ -11,16 +17,6 @@
|
|||
* Will Rossiter
|
||||
<will (at) fullscreen (dot) io>
|
||||
|
||||
## Requirements
|
||||
|
||||
Silverstripe 4.0+
|
||||
|
||||
**Note:** For Silverstripe 3.x, please use the [2.x release line](https://github.com/silverstripe/silverstripe-spamprotection/tree/2.0).
|
||||
|
||||
## Install
|
||||
|
||||
To install run `composer require silverstripe/spamprotection`.
|
||||
|
||||
## Documentation
|
||||
|
||||
This module provides a generic, consistent API for adding spam protection to
|
||||
|
@ -32,6 +28,7 @@ implementations. Currently available options are:
|
|||
* [MathSpamProtection](https://github.com/silverstripe/silverstripe-mathspamprotection)
|
||||
* [Akismet](https://github.com/silverstripe/silverstripe-akismet)
|
||||
* [Mollom](https://github.com/silverstripe-archive/silverstripe-mollom)
|
||||
* [Cloudflare Turnstile](https://github.com/silverstripe-terraformers/turnstile-captcha/)
|
||||
|
||||
As a developer you can also provide your own protector by creating a class which
|
||||
implements the `\SilverStripe\SpamProtection\SpamProtector` interface. More on that below.
|
||||
|
|
|
@ -17,14 +17,16 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0",
|
||||
"silverstripe/framework": "^4.10"
|
||||
"php": "^8.1",
|
||||
"silverstripe/framework": "^5"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"silverstripe/versioned": "^1.0",
|
||||
"squizlabs/php_codesniffer": "^3.0",
|
||||
"silverstripe/userforms": "^5"
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"silverstripe/versioned": "^2",
|
||||
"squizlabs/php_codesniffer": "^3",
|
||||
"silverstripe/userforms": "^6",
|
||||
"silverstripe/standards": "^1",
|
||||
"phpstan/extension-installer": "^1.3"
|
||||
},
|
||||
"extra": {
|
||||
"expose": [
|
||||
|
@ -33,11 +35,11 @@
|
|||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SilverStripe\\SpamProtection\\": "code/",
|
||||
"SilverStripe\\SpamProtection\\": "src/",
|
||||
"SilverStripe\\SpamProtection\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
Name: spamprotectionlegacy
|
||||
---
|
||||
SilverStripe\ORM\DatabaseAdmin:
|
||||
classname_value_remapping:
|
||||
EditableSpamProtectionField: 'SilverStripe\SpamProtection\EditableSpamProtectionField'
|
|
@ -2,7 +2,7 @@
|
|||
<ruleset name="SilverStripe">
|
||||
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
|
||||
|
||||
<file>code</file>
|
||||
<file>src</file>
|
||||
<file>tests</file>
|
||||
|
||||
<rule ref="PSR2" >
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
parameters:
|
||||
paths:
|
||||
- src
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">code/</directory>
|
||||
<directory suffix=".php">src/</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">tests/</directory>
|
||||
</exclude>
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
namespace SilverStripe\SpamProtection;
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FieldGroup;
|
||||
|
@ -41,15 +40,15 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
* @var array
|
||||
* @config
|
||||
*/
|
||||
private static $check_fields = array(
|
||||
private static $check_fields = [
|
||||
EditableEmailField::class,
|
||||
EditableTextField::class,
|
||||
EditableNumericField::class
|
||||
);
|
||||
];
|
||||
|
||||
private static $db = array(
|
||||
private static $db = [
|
||||
'SpamFieldSettings' => 'Text'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @var FormField
|
||||
|
@ -69,7 +68,7 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
}
|
||||
|
||||
// Extract saved field mappings and update this field.
|
||||
$fieldMapping = array();
|
||||
$fieldMapping = [];
|
||||
foreach ($this->getCandidateFields() as $otherField) {
|
||||
$mapSetting = "Map-{$otherField->Name}";
|
||||
$spamField = $this->spamMapValue($mapSetting);
|
||||
|
@ -99,14 +98,14 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
/**
|
||||
* Gets the list of all candidate spam detectable fields on this field's form
|
||||
*
|
||||
* @return DataList
|
||||
* @return DataList<EditableFormField>
|
||||
*/
|
||||
protected function getCandidateFields()
|
||||
{
|
||||
|
||||
// Get list of all configured classes available for spam detection
|
||||
$types = $this->config()->get('check_fields');
|
||||
$typesInherit = array();
|
||||
$typesInherit = [];
|
||||
foreach ($types as $type) {
|
||||
$subTypes = ClassInfo::subclassesFor($type);
|
||||
$typesInherit = array_merge($typesInherit, $subTypes);
|
||||
|
@ -132,7 +131,7 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
{
|
||||
$fieldMap = json_decode($this->SpamFieldSettings ?? '', true);
|
||||
if (empty($fieldMap)) {
|
||||
$fieldMap = array();
|
||||
$fieldMap = [];
|
||||
}
|
||||
|
||||
foreach ($this->record as $key => $value) {
|
||||
|
@ -152,7 +151,6 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
*/
|
||||
public function getCMSFields()
|
||||
{
|
||||
/** @var FieldList $fields */
|
||||
$fields = parent::getCMSFields();
|
||||
|
||||
// Get protector
|
||||
|
@ -202,7 +200,7 @@ class EditableSpamProtectionField extends EditableFormField
|
|||
{
|
||||
$map = json_decode($this->SpamFieldSettings ?? '', true);
|
||||
if (empty($map)) {
|
||||
$map = array();
|
||||
$map = [];
|
||||
}
|
||||
|
||||
if (array_key_exists($mapSetting, $map ?? [])) {
|
|
@ -2,31 +2,31 @@
|
|||
|
||||
namespace SilverStripe\SpamProtection\Extension;
|
||||
|
||||
use SilverStripe\Comments\Controllers\CommentingController;
|
||||
use SilverStripe\Core\Extension;
|
||||
|
||||
/**
|
||||
* Apply the spam protection to the comments module if it is installed.
|
||||
*
|
||||
* @package spamprotection
|
||||
* @extends Extension<CommentingController>
|
||||
*/
|
||||
|
||||
class CommentSpamProtection extends Extension
|
||||
{
|
||||
public function alterCommentForm(&$form)
|
||||
{
|
||||
$form->enableSpamProtection(array(
|
||||
$form->enableSpamProtection([
|
||||
'name' => 'IsSpam',
|
||||
'mapping' => array(
|
||||
'mapping' => [
|
||||
'Name' => 'authorName',
|
||||
'Email' => 'authorEmail',
|
||||
'URL' => 'authorUrl',
|
||||
'Comment' => 'body',
|
||||
'ReturnURL' => 'contextUrl'
|
||||
),
|
||||
'checks' => array(
|
||||
],
|
||||
'checks' => [
|
||||
'spam',
|
||||
'profanity'
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -6,14 +6,14 @@ use LogicException;
|
|||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Forms\Form;
|
||||
|
||||
/**
|
||||
* An extension to the {@link Form} class which provides the method
|
||||
* {@link enableSpamProtection()} helper.
|
||||
*
|
||||
* @package spamprotection
|
||||
* @extends Extension<Form>
|
||||
*/
|
||||
|
||||
class FormSpamProtectionExtension extends Extension
|
||||
{
|
||||
use Configurable;
|
||||
|
@ -37,7 +37,7 @@ class FormSpamProtectionExtension extends Extension
|
|||
*
|
||||
* @var array $mappable_fields
|
||||
*/
|
||||
private static $mappable_fields = array(
|
||||
private static $mappable_fields = [
|
||||
'id',
|
||||
'title',
|
||||
'body',
|
||||
|
@ -48,7 +48,7 @@ class FormSpamProtectionExtension extends Extension
|
|||
'authorUrl',
|
||||
'authorIp',
|
||||
'authorId'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @config
|
||||
|
@ -86,9 +86,9 @@ class FormSpamProtectionExtension extends Extension
|
|||
*
|
||||
* @param array $options
|
||||
* @throws LogicException when get_protector method returns NULL.
|
||||
* @return Object
|
||||
* @return Form
|
||||
*/
|
||||
public function enableSpamProtection($options = array())
|
||||
public function enableSpamProtection($options = [])
|
||||
{
|
||||
|
||||
// captcha form field name (must be unique)
|
Loading…
Reference in New Issue