Skip to content

ci: add security check workflow #732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/apply-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ name: 🏷️ Add labels

jobs:
label:
uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@master
uses: wayofdev/gh-actions/.github/workflows/apply-labels.yml@v3.1.0
with:
os: ubuntu-latest
secrets:
Expand Down
File renamed without changes.
29 changes: 0 additions & 29 deletions .github/workflows/create-arch-diagram.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🎉 Create release
uses: google-github-actions/release-please-action@v4
uses: googleapis/release-please-action@v4.1.1
id: release
with:
token: ${{ secrets.PERSONAL_GITHUB_TOKEN }}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/security-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---

name: 🔐 Security analysis

on: # yamllint disable-line rule:truthy
push:
branches:
- master
pull_request:
branches:
- master

jobs:
security-analysis:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The matrix strategy in the security-analysis.yml file currently includes only ubuntu-latest. It does not include ubuntu-22.04, which is used in the ci.yml workflow.

  • .github/workflows/security-analysis.yml:

    matrix:
      os:
        - ubuntu-latest
  • .github/workflows/ci.yml:

    os: ["ubuntu-22.04"]

To ensure consistency and coverage, consider adding ubuntu-22.04 to the matrix strategy in the security-analysis.yml file.

Analysis chain

Ensure that the matrix strategy includes all necessary operating systems.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all necessary operating systems are included in the matrix strategy.

# Test: List all operating systems used in other workflows to compare.
rg 'os:' .github/workflows/*.yml

Length of output: 508



Script:

#!/bin/bash
# Description: Extract the matrix strategy from security-analysis.yml to verify the included operating systems.

# Test: Extract the matrix strategy from the security-analysis.yml file.
rg 'matrix:' -A 10 .github/workflows/security-analysis.yml

Length of output: 280

concurrency:
cancel-in-progress: true
group: security-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
php-version:
- '8.2'
dependencies:
- locked
steps:
- name: 📦 Check out the codebase
uses: actions/[email protected]

- name: 🛠️ Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql
ini-values: error_reporting=E_ALL
coverage: none

- name: 🛠️ Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: 🤖 Validate composer.json and composer.lock
run: composer validate --ansi --strict

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/[email protected]

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/[email protected]
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
dependencies: ${{ matrix.dependencies }}

- name: 🐛 Check installed packages for security vulnerability advisories
run: composer audit --ansi
2 changes: 1 addition & 1 deletion .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ permissions:

jobs:
shellcheck:
uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@master
uses: wayofdev/gh-actions/.github/workflows/shellcheck.yml@v3.1.0
with:
os: ubuntu-latest
severity: warning
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---

on: # yamllint disable-line rule:truthy
push:
branches:
- master
paths:
- 'config/**'
- 'src/**'
- 'tests/**'
- '.php-cs-fixer.dist.php'
pull_request:
branches:
- master
paths:
- 'config/**'
- 'src/**'
- 'tests/**'
- '.php-cs-fixer.dist.php'

name: 🔍 Static analysis

jobs:
static-analysis:
timeout-minutes: 4
runs-on: ${{ matrix.os }}
concurrency:
cancel-in-progress: true
group: static-analysis-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
strategy:
fail-fast: true
matrix:
os:
- ubuntu-latest
php-version:
- '8.2'
dependencies:
- locked
steps:
- name: 📦 Check out the codebase
uses: actions/[email protected]

- name: 🛠️ Setup PHP
uses: shivammathur/[email protected]
with:
php-version: ${{ matrix.php-version }}
extensions: none, ctype, dom, json, mbstring, simplexml, tokenizer, xml, xmlwriter, pdo, curl, fileinfo, pdo_mysql
ini-values: error_reporting=E_ALL
coverage: none

- name: 🛠️ Setup problem matchers
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: 🤖 Validate composer.json and composer.lock
run: composer validate --ansi --strict

- name: 🔍 Get composer cache directory
uses: wayofdev/gh-actions/actions/composer/[email protected]

- name: ♻️ Restore cached dependencies installed with composer
uses: actions/[email protected]
with:
path: ${{ env.COMPOSER_CACHE_DIR }}
key: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}
restore-keys: php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-

- name: 📥 Install "${{ matrix.dependencies }}" dependencies
uses: wayofdev/gh-actions/actions/composer/[email protected]
with:
dependencies: ${{ matrix.dependencies }}

- name: 🔍 Run static analysis using phpstan/phpstan
run: composer stan:ci
3 changes: 2 additions & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="composer-require-checker" version="^4.10.0" installed="4.10.0" location="./.phive/composer-require-checker" copy="false"/>
<phar name="composer-normalize" version="^2.42.0" installed="2.42.0" location="./.phive/composer-normalize" copy="false"/>
<phar name="composer-require-checker" version="^4.11.0" installed="4.11.0" location="./.phive/composer-require-checker" copy="false"/>
</phive>
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ update: ## Updates composer dependencies by running composer update command
.PHONY: update

phive: ## Installs dependencies with phive
$(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0x033E5F8D801A2F8D
$(APP_RUNNER) /usr/local/bin/phive install --trust-gpg-keys 0xC00543248C87FB13,0x033E5F8D801A2F8D
.PHONY: phive

#
Expand Down Expand Up @@ -241,7 +241,7 @@ lint-deps: ## Runs composer-require-checker – checks for dependencies that are
.PHONY: lint-deps

lint-composer: ## Normalize composer.json and composer.lock files
$(APP_COMPOSER) normalize
$(APP_RUNNER) .phive/composer-normalize normalize
.PHONY: lint-composer

lint-audit: ## Runs security checks for composer dependencies
Expand Down
33 changes: 25 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"description": "🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.",
"license": "MIT",
"type": "library",
"version": "4.12.3",
"keywords": [
"php",
"php8",
Expand Down Expand Up @@ -44,6 +43,7 @@
],
"require": {
"php": "^8.2",
"ext-fileinfo": "*",
"ext-pdo": "*",
"cycle/annotated": "^4.1",
"cycle/database": "^2.8",
Expand All @@ -62,8 +62,9 @@
"symfony/console": "^6.4 || ^7.0"
},
"require-dev": {
"ext-curl": "*",
"ext-pdo_mysql": "*",
"beberlei/assert": "^3.3",
"ergebnis/composer-normalize": "^2.42",
"fakerphp/faker": "^1.23",
"larastan/larastan": "^2.9",
"laravel/telescope": "^5.0",
Expand All @@ -80,13 +81,18 @@
"psalm/plugin-phpunit": "~0.19.0",
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.35",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^5.23.1",
"wayofdev/cs-fixer-config": "^1.2"
},
"suggest": {
"ext-pdo_mysql": "Required for MySQL database support",
"ext-pdo_pgsql": "Required for PostgreSQL database support",
"ext-pdo_sqlite": "Required for SQLite database support",
"cycle/active-record": "Provides a simple way to work with your database using Active Record pattern and Cycle ORM",
"wayofdev/cs-fixer-config": "A set of PHP-CS-Fixer rules for Laravel projects",
"wayofdev/laravel-cycle-orm-factories": "Cycle-ORM Entity Factories and Database Seeders for Laravel",
"wayofdev/laravel-paginator": "Custom Laravel Paginator for Cycle-ORM implementing RFC 5988"
"wayofdev/laravel-paginator": "Custom Laravel Paginator for Cycle-ORM implementing RFC 5988",
"wayofdev/laravel-symfony-serializer": "Symfony Serializer for Laravel"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand All @@ -108,6 +114,9 @@
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
},
"platform": {
"php": "8.2.19"
},
"sort-packages": true
},
"extra": {
Expand All @@ -132,11 +141,13 @@
"cs:fix": "php vendor/bin/php-cs-fixer fix -v",
"infect": [
"Composer\\Config::disableProcessTimeout",
"XDEBUG_MODE=coverage php vendor/bin/roave-infection-static-analysis-plugin --threads=2 --configuration=infection.json.dist"
"@putenv XDEBUG_MODE=coverage",
"php vendor/bin/roave-infection-static-analysis-plugin --threads=2"
],
"infect:ci": [
"Composer\\Config::disableProcessTimeout",
"XDEBUG_MODE=coverage php vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ansi --configuration=infection.json.dist --logger-github --ignore-msi-with-no-mutations --only-covered"
"@putenv XDEBUG_MODE=coverage",
"php vendor/bin/roave-infection-static-analysis-plugin --threads=2 --ansi --logger-github --ignore-msi-with-no-mutations --only-covered"
],
"psalm": "php vendor/bin/psalm --show-info=true",
"psalm:baseline": "php vendor/bin/psalm --set-baseline=psalm-baseline.xml",
Expand All @@ -146,7 +157,13 @@
"stan": "php vendor/bin/phpstan analyse --memory-limit=2G",
"stan:baseline": "php vendor/bin/phpstan analyse --generate-baseline --memory-limit=2G --allow-empty-baseline",
"stan:ci": "php vendor/bin/phpstan analyse --memory-limit=2G --error-format=github",
"test": "XDEBUG_MODE=coverage php vendor/bin/pest",
"test:cc": "XDEBUG_MODE=coverage php vendor/bin/pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml"
"test": [
"@putenv XDEBUG_MODE=coverage",
"php vendor/bin/pest"
],
"test:cc": [
"@putenv XDEBUG_MODE=coverage",
"php vendor/bin/pest --coverage --coverage-clover=.build/phpunit/logs/clover.xml"
]
}
}
Loading