Skip to content

Commit

Permalink
Initial commit to Github
Browse files Browse the repository at this point in the history
  • Loading branch information
curry684 committed Nov 4, 2023
0 parents commit d61475e
Show file tree
Hide file tree
Showing 103 changed files with 4,277 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
pull_request:
push:
branches:
- master

jobs:
run:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php:
- '8.1'
- '8.2'
- '8.3'
os: [ ubuntu-latest ]
experimental: [ false ]
symfony-versions: [false]
include:
- description: 'PHP nightly'
php: '8.4'
experimental: true
- description: 'unstable dependencies'
php: '8.1'
use-beta: true
experimental: true
- description: 'lowest dependencies'
php: '8.1'
lowest: true

name: PHP ${{ matrix.php }} ${{ matrix.description }}
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: ${{ matrix.php }}-${{ matrix.symfony-versions }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Allow beta dependencies
run: composer config minimum-stability beta
if: matrix.use-beta

- name: Install dependencies
run: composer update ${{ matrix.lowest && '--prefer-lowest --prefer-stable }}

- name: Run PHPStan static analysis
run: vendor/bin/phpstan

- name: Check for dangerous and broken dependencies
run: composer audit

- name: Run automated tests
run: vendor/bin/phpunit --coverage-text

- name: Run infection tests
run: vendor/bin/infection --threads=max
30 changes: 30 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci

on:
push:
branches:
- master

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV

- uses: actions/cache@v3
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: pip install mkdocs-material mkdocs-material-extensions
- run: mkdocs gh-deploy --force
working-directory: ./docs
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/.*.cache
/.idea
/composer.lock
/build
/infection
/log
/tmp
/vendor
*~
50 changes: 50 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
* Symfony Anti-Spam Bundle
* (c) Omines Internetbureau B.V. - https://omines.nl/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

$header = <<<EOF
Symfony Anti-Spam Bundle
(c) Omines Internetbureau B.V. - https://omines.nl/
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF;

$finder = PhpCsFixer\Finder::create()
->files()
->name('*.php')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')->exclude('Fixture')
->in(__DIR__ . '/tests/Fixture/src')
;

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,

'declare_strict_types' => true,
'strict_param' => true,
'strict_comparison' => true,
'array_syntax' => ['syntax' => 'short'],
'concat_space' => ['spacing' => 'one'],
'header_comment' => ['header' => $header, 'location' => 'after_open'],

'mb_str_functions' => true,
'ordered_imports' => true,
'phpdoc_align' => false,
'phpdoc_separation' => false,
'phpdoc_var_without_name' => false,
])
->setFinder($finder)
;
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog
All notable changes to `omines\antispam-bundle` will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
Nothing yet.
46 changes: 46 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Contributing

Contributions are **welcome** and will be credited.

We accept contributions via Pull Requests on [Github](https://github.com/omines/antispam-bundle).
Follow [good standards](http://www.phptherightway.com/), keep the PHPstan level maxed, include tests with proper
coverage, and run `bin/prepare-commit` during development and before committing.

Infection testing is not done automatically, but it is *recommended* to run `bin/infection`
before finishing a PR.

## Running a test environment

There is a full Symfony test project in `tests/Fixture` for functional testing. It can be run
standalone as well if you have the Symfony CLI installed for easy development:

```sh
bin/testsite
```

## Update documentation

To generate the mkdocs site in `/docs` run:

```sh
pip install mkdocs mkdocs-material mkdocs-material-extensions
bin/serve-docs
```
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 and beyond, Omines Internetbureau B.V.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Symfony Anti-Spam Bundle
[![Latest Stable Version](https://poser.pugx.org/omines/antispam-bundle/version)](https://packagist.org/packages/omines/antispam-bundle)
[![Total Downloads](https://poser.pugx.org/omines/antispam-bundle/downloads)](https://packagist.org/packages/omines/antispam-bundle)
[![Latest Unstable Version](https://poser.pugx.org/omines/antispam-bundle/v/unstable)](//packagist.org/packages/omines/antispam-bundle)
[![License](https://poser.pugx.org/omines/antispam-bundle/license)](https://packagist.org/packages/omines/antispam-bundle)

You have found the Swiss Army Knife of battling form spam in your Symfony application!

This bundle provides a ton of different mechanisms for detecting and stopping spammers,
scammers and abusers using your forms for their nefarious purposes, and brings them
all together in an easy to configure profile system.

This bundle is compatible with PHP 8.1+ and Symfony 6.3 or later.

## What does it do

This bundle provides you with a ton of methods to easily combat spam through tested and
proven methods:

- *Honeypot*:

## Quickstart

Install the bundle:
```sh
composer require omines/antispam-bundle
```
Symfony Flex will enable the bundle and provide a basic configuration file with samples
at `config/packages/antispam.yaml`.

## Contributing

Please see [CONTRIBUTING.md](https://github.com/omines/antispam-bundle/blob/master/CONTRIBUTING.md) for details.

## Legal

This software was developed for internal use at [Omines Full Service Internetbureau](https://www.omines.nl/)
in Eindhoven, the Netherlands. It is shared with the general public under the permissive MIT license, without
any guarantee of fitness for any particular purpose. Refer to the included `LICENSE` file for more details.
11 changes: 11 additions & 0 deletions bin/infection
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -e
cd $(dirname $0)/..

export APP_ENV=test
export APP_DEBUG=1
export XDEBUG_MODE=coverage

# Next line not needed for now as the composer level integration works fine
#[ ! -f "infection/infection.phar" ] && bin/install-infection
vendor/bin/infection --threads=max $@
11 changes: 11 additions & 0 deletions bin/install-infection
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
cd $(dirname $0)/..

wget https://github.com/infection/infection/releases/download/0.27.0/infection.phar
wget https://github.com/infection/infection/releases/download/0.27.0/infection.phar.asc
gpg --recv-keys C6D76C329EBADE2FB9C458CFC5095986493B4AA0
gpg --with-fingerprint --verify infection.phar.asc infection.phar
rm infection.phar.asc*
chmod +x infection.phar
mkdir -p infection
mv infection.phar build
21 changes: 21 additions & 0 deletions bin/prepare-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
set -e
cd $(dirname $0)/..

export APP_ENV=test
export APP_DEBUG=1
export XDEBUG_MODE=coverage

vendor/bin/php-cs-fixer fix
vendor/bin/phpstan

# Clear cache manually to avoid locking up with corrupted container
rm -rf tests/fixture/var/cache/test
php -d "zend.assertions=1" vendor/bin/phpunit --coverage-text --display-warnings \
--coverage-xml=build/coverage/coverage-xml --log-junit=build/coverage/junit.xml

# Run with lower MSI in diff-filter mode as it doesn't include coverage from other tests
vendor/bin/infection --threads=max --git-diff-filter=AM --min-msi=80 --min-covered-msi=80 \
--coverage=build/coverage

echo "All good, ready for commit!"
8 changes: 8 additions & 0 deletions bin/serve-docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
set -e
cd $(dirname $0)/../docs

echo "If need be install mkdocs with 'apt install mkdocs-material mkdocs-material-extensions'"
echo "You can choose a different port with 'bin/serve-docs -a 127.0.0.1:4000'"
echo
mkdocs serve $@
5 changes: 5 additions & 0 deletions bin/testsite
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -e
cd $(dirname $0)/../tests/Fixture

symfony serve --no-tls $@
Loading

0 comments on commit d61475e

Please sign in to comment.