Skip to content
Snippets Groups Projects
Commit 016f1153 authored by MENACER Mohamed's avatar MENACER Mohamed
Browse files

test3

parent bbaa7c6a
No related branches found
No related tags found
1 merge request!3test3
Pipeline #47524 failed
Showing
with 10677 additions and 139 deletions
name: Security Audit
on: [push, pull_request]
jobs:
audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
- name: Setup Cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Caching deps
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php8.3-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php8.3-composer-latest-
- name: Update composer
run: composer self-update
- name: install deps
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: security audit
run: |
composer audit \
--no-dev \
--abandoned="report" \
--ignore-severity="low" \
--ignore-severity="medium" \
--format="json" \
--no-ansi \
> /tmp/security-audit.json
- name: upload security audit report
uses: actions/upload-artifact@v4
if: always()
with:
name: security-audit
path: /tmp/security-audit.json
name: Quality Analysis
on: [push, pull_request]
jobs:
quality:
name: Quality Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
- name: Setup Cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Caching deps
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php8.3-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php8.3-composer-latest-
- name: Update composer
run: composer self-update
- name: install deps
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Quality analysis
run: composer app:code-quality
name: Tests
on: [push, pull_request]
jobs:
test:
name: Tests
runs-on: ubuntu-latest
services:
database:
image: mariadb:10.7.3
env:
MARIADB_USER: root
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: app_test
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'no'
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
tools: composer:v2
- name: Setup Cache
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
- name: Caching deps
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php8.3-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
php8.3-composer-latest-
- name: Update composer
run: composer self-update
- name: install deps
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
- name: Prepare the database
run: sudo systemctl start mysql
- name: Tests
run: composer app:tests
env:
APP_ENV: test
DATABASE_URL: mysql://root:root@127.0.0.1:${{ job.services.database.ports['3306'] }}/app_test
stages:
- install
- test
- deploy # Optionnel, à activer si nécessaire
variables:
PHP_VERSION: "8.2"
COMPOSER_CACHE_DIR: "$CI_PROJECT_DIR/var/cache/composer"
cache:
key: composer
paths:
- vendor/
- var/cache/composer/
install_dependencies:
stage: install
image: php:$PHP_VERSION
script:
- apt-get update && apt-get install -y unzip git
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- composer install --no-interaction --prefer-dist
artifacts:
paths:
- vendor/
run_tests:
stage: test
image: php:$PHP_VERSION
script:
- ./bin/phpunit
# Déploiement (à adapter selon ton serveur)
deploy:
stage: deploy
only:
- main # Modifier selon la branche utilisée
script:
- echo "Déploiement en cours..."
# Ajouter ici les commandes pour le déploiement
import './bootstrap.js';
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import './styles/app.css';
console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
import { startStimulusApp } from '@symfony/stimulus-bundle';
const app = startStimulusApp();
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
{
"controllers": {
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
"fetch": "eager"
},
"mercure-turbo-stream": {
"enabled": false,
"fetch": "eager"
}
}
},
"entrypoints": []
}
var nameCheck = /^[-_a-zA-Z0-9]{4,22}$/;
var tokenCheck = /^[-_/+a-zA-Z0-9]{24,}$/;
// Generate and double-submit a CSRF token in a form field and a cookie, as defined by Symfony's SameOriginCsrfTokenManager
document.addEventListener('submit', function (event) {
var csrfField = event.target.querySelector('input[data-controller="csrf-protection"]');
if (!csrfField) {
return;
}
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
var csrfToken = csrfField.value;
if (!csrfCookie && nameCheck.test(csrfToken)) {
csrfField.setAttribute('data-csrf-protection-cookie-value', csrfCookie = csrfToken);
csrfField.value = csrfToken = btoa(String.fromCharCode.apply(null, (window.crypto || window.msCrypto).getRandomValues(new Uint8Array(18))));
}
if (csrfCookie && tokenCheck.test(csrfToken)) {
var cookie = csrfCookie + '_' + csrfToken + '=' + csrfCookie + '; path=/; samesite=strict';
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
}
});
// When @hotwired/turbo handles form submissions, send the CSRF token in a header in addition to a cookie
// The `framework.csrf_protection.check_header` config option needs to be enabled for the header to be checked
document.addEventListener('turbo:submit-start', function (event) {
var csrfField = event.detail.formSubmission.formElement.querySelector('input[data-controller="csrf-protection"]');
if (!csrfField) {
return;
}
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
event.detail.formSubmission.fetchRequest.headers[csrfCookie] = csrfField.value;
}
});
// When @hotwired/turbo handles form submissions, remove the CSRF cookie once a form has been submitted
document.addEventListener('turbo:submit-end', function (event) {
var csrfField = event.detail.formSubmission.formElement.querySelector('input[data-controller="csrf-protection"]');
if (!csrfField) {
return;
}
var csrfCookie = csrfField.getAttribute('data-csrf-protection-cookie-value');
if (tokenCheck.test(csrfField.value) && nameCheck.test(csrfCookie)) {
var cookie = csrfCookie + '_' + csrfField.value + '=0; path=/; samesite=strict; max-age=0';
document.cookie = window.location.protocol === 'https:' ? '__Host-' + cookie + '; secure' : cookie;
}
});
/* stimulusFetch: 'lazy' */
export default 'csrf-protection-controller';
import { Controller } from '@hotwired/stimulus';
/*
* This is an example Stimulus controller!
*
* Any element with a data-controller="hello" attribute will cause
* this controller to be executed. The name "hello" comes from the filename:
* hello_controller.js -> "hello"
*
* Delete this file or adapt it for your use!
*/
export default class extends Controller {
connect() {
this.element.textContent = 'Hello Stimulus! Edit me in assets/controllers/hello_controller.js';
}
}
body {
background-color: skyblue;
}
#!/usr/bin/env php
<?php
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
return new Application($kernel);
};
#!/usr/bin/env php
<?php
if (!ini_get('date.timezone')) {
ini_set('date.timezone', 'UTC');
}
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
if (PHP_VERSION_ID >= 80000) {
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit';
} else {
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";
exit(1);
}
require dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php';
}
services:
php:
# pour eviter le erreur de permission
user: '${USER_ID:-1000}:${GROUP_ID:-1000}'
build: ./docker/php
volumes:
- .:/var/www:delegated # le dossier courant sera monté dans le dossier /var/www du container
depends_on: # ce service depend de la base de donnée, sinon je ne peux pas engistrer mes utilisateurs
- database
networks:
- app_network
# un serveur web qui va intercepeté les requêtes et les rediriger vers PHP qui va les traiter et retourner le résultat
nginx:
build: ./docker/nginx
volumes:
- ./public:/var/www/public:delegated
- ./docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- "8000:80"
depends_on: #sinon on sera pas interprété les requêtes
- php
networks:
- app_network
database:
image: mariadb:10.7.3
environment:
MARIADB_USER: root
MARIADB_ROOT_PASSWORD: root
MARIADB_DATABASE: app
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: 'no'
volumes:
- database_data:/var/lib/mysql:rw #ou les données de la base de données seront stocké
- .var/mysql:/var/www/var
networks:
- app_network # ce n'est pas trés important car parce que tous les services qui sont définis seront dans le même réseau
adminer: # permet de voir tous ce qu'il y'a dans la base de donnée et permet de débugger si les requêtes fonctionnent comme il faut
image: adminer:latest
depends_on: # ce service depend de la base de donnée, ça sert à rien de le lancer si database n'est pas UP !
- database
environment:
APP_ENV: dev #environement de dev par default
ADMINER_DESIGN: pepa-linha # le design utilisé par default
ADMINER_DEFAULT_SERVER: # serveur utilisé par default
ports: # c'est comment accéder au "adminer" une fois le contenair sera lancé (port forwading)
- "8082:8080" # le adminer va tourner dans le port 8080, mais ce port la c'est dans le contenair et on a pas accés à ce port via la machine hots
networks: # on va rediriger le port 8082 vers le port interne 8080 du container
- app_network
mailer: # Pour envoyer les emails nous avons besoin d'un mailer
image: axllent/mailpit
ports:
- "1025:1025" # ca pour le port SMTP qui va permettre d'envoyer les mails
- "8025:8025" # ca pour le port du serveur web qui va permettre d'afficher les emails qui ont étés envoyer
environment: # définir si on accepter les connexion non sécurisé
MP_SMTP_AUTH_ACCEPT_ANY: 1
MP_SMTP_AUTH_ALLOW_INSECURE: 1
networks:
- app_network
networks:
app_network:
volumes:
database_data: #cette clé il faut la crée
\ No newline at end of file
{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.13",
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.3",
"phpdocumentor/reflection-docblock": "^5.6",
"phpstan/phpdoc-parser": "^2.0",
"symfony/asset": "7.2.*",
"symfony/asset-mapper": "7.2.*",
"symfony/console": "7.2.*",
"symfony/doctrine-messenger": "7.2.*",
"symfony/dotenv": "7.2.*",
"symfony/expression-language": "7.2.*",
"symfony/flex": "^2",
"symfony/form": "7.2.*",
"symfony/framework-bundle": "7.2.*",
"symfony/http-client": "7.2.*",
"symfony/intl": "7.2.*",
"symfony/mailer": "7.2.*",
"symfony/mime": "7.2.*",
"symfony/monolog-bundle": "^3.0",
"symfony/notifier": "7.2.*",
"symfony/process": "7.2.*",
"symfony/property-access": "7.2.*",
"symfony/property-info": "7.2.*",
"symfony/runtime": "7.2.*",
"symfony/security-bundle": "7.2.*",
"symfony/serializer": "7.2.*",
"symfony/stimulus-bundle": "^2.22",
"symfony/string": "7.2.*",
"symfony/translation": "7.2.*",
"symfony/twig-bundle": "7.2.*",
"symfony/ux-turbo": "^2.22",
"symfony/validator": "7.2.*",
"symfony/web-link": "7.2.*",
"symfony/yaml": "7.2.*",
"symfonycasts/verify-email-bundle": "^1.17",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
},
"config": {
"allow-plugins": {
"php-http/discovery": true,
"symfony/flex": true,
"symfony/runtime": true
},
"bump-after-update": true,
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*",
"symfony/polyfill-php73": "*",
"symfony/polyfill-php74": "*",
"symfony/polyfill-php80": "*",
"symfony/polyfill-php81": "*",
"symfony/polyfill-php82": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"importmap:install": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
],
"app:code-quality": [
"./vendor/bin/ecs check",
"bin/console lint:yaml config --parse-tags",
"bin/console lint:twig templates",
"bin/console lint:container",
"./vendor/bin/phpstan analyse --memory-limit=-1",
"./vendor/bin/rector --dry-run"
],
"app:migration": [
"bin/console doctrine:migrations:migrate"
],
"app:tests": [
"bin/console doctrine:database:drop --force --if-exists --env=test",
"bin/console doctrine:database:create --env=test",
"bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration --env=test",
"bin/console cache:clear --env=test",
"bin/phpunit"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.2.*"
}
},
"require-dev": {
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.5",
"rector/rector": "^2.0",
"symfony/browser-kit": "7.2.*",
"symfony/css-selector": "7.2.*",
"symfony/debug-bundle": "7.2.*",
"symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^7.2",
"symfony/stopwatch": "7.2.*",
"symfony/web-profiler-bundle": "7.2.*",
"symplify/easy-coding-standard": "^12.5"
}
}
This diff is collapsed.
<?php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
SymfonyCasts\Bundle\VerifyEmail\SymfonyCastsVerifyEmailBundle::class => ['all' => true],
];
framework:
asset_mapper:
# The paths to make available to the asset mapper.
paths:
- assets/
missing_import_mode: strict
when@prod:
framework:
asset_mapper:
missing_import_mode: warn
framework:
cache:
# Unique name of your app: used to compute stable namespaces for cache keys.
#prefix_seed: your_vendor_name/app_name
# The "app" cache stores to the filesystem by default.
# The data in this cache should persist between deploys.
# Other options include:
# Redis
#app: cache.adapter.redis
#default_redis_provider: redis://localhost
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
#app: cache.adapter.apcu
# Namespaced pools use the above "app" backend by default
#pools:
#my.dedicated.cache: null
# Enable stateless CSRF protection for forms and logins/logouts
framework:
form:
csrf_protection:
token_id: submit
csrf_protection:
stateless_token_ids:
- submit
- authenticate
- logout
when@dev:
debug:
# Forwards VarDumper Data clones to a centralized server allowing to inspect dumps on CLI or in your browser.
# See the "server:dump" command to start a new server.
dump_destination: "tcp://%env(VAR_DUMPER_SERVER)%"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment