-
Couldn't load subscription status.
- Fork 2
WIP: Creating the module #1
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
Parent:
Get deveopment up to date
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
488a30a
ITKDev: Started on audit log module
cableman b061683
ITKDev: Added better logging options
cableman d016055
ITKDev: Added code style checking
cableman 5adceb0
ITKDev: Added exception hanling
cableman fcbb5a9
ITKDev: Added identity to loki log messages
cableman f10132b
ITKDev: Tried to update readme with usefull information
cableman 52aeaac
ITKDev: Fixed code style
cableman 0c08665
ITKDev: Minor user id fix
cableman 575cb09
ITKDev: Update README.md
cableman 12d7349
ITKDev: Update os2web_audit.links.menu.yml
cableman 9228695
ITKDev: Update os2web_audit.links.task.yml
cableman 6efc85e
ITKDev: Update os2web_audit.routing.yml
cableman 7d9ebb0
ITKDev: Update phpcs.xml.dist
cableman caa34a6
ITKDev: Update phpcs.xml.dist
cableman 29dcb76
ITKDev: Update src/Form/PluginSettingsForm.php
cableman 029b8b3
ITKDev: Minor code review changes
cableman d20b087
Merge branch 'develop' of https://github.com/os2web/os2web_audit into…
cableman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #### Link to ticket | ||
|
|
||
| Please add a link to the ticket being addressed by this change. | ||
|
|
||
| #### Description | ||
|
|
||
| Please include a short description of the suggested change and the reasoning behind the approach you have chosen. | ||
|
|
||
| #### Screenshot of the result | ||
|
|
||
| If your change affects the user interface you should include a screenshot of the result with the pull request. | ||
|
|
||
| #### Checklist | ||
|
|
||
| - [ ] My code passes our static analysis suite. | ||
| - [ ] My code passes our continuous integration process. | ||
|
|
||
| If your code does not pass all the requirements on the checklist you have to add a comment explaining why this change | ||
| should be exempt from the list. | ||
|
|
||
| #### Additional comments or questions | ||
|
|
||
| If you have any further comments or questions for the reviewer please add them here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| on: pull_request | ||
| name: Review | ||
| jobs: | ||
| changelog: | ||
| runs-on: ubuntu-latest | ||
| name: Changelog should be updated | ||
| strategy: | ||
| fail-fast: false | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| fetch-depth: 2 | ||
|
|
||
| - name: Git fetch | ||
| run: git fetch | ||
|
|
||
| - name: Check that changelog has been updated. | ||
| run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 | ||
|
|
||
| test-composer-files: | ||
| name: Validate composer | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| php-versions: [ '8.1' ] | ||
| dependency-version: [ prefer-lowest, prefer-stable ] | ||
| steps: | ||
| - uses: actions/checkout@master | ||
| - name: Setup PHP, with composer and extensions | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-versions }} | ||
| extensions: json | ||
| coverage: none | ||
| tools: composer:v2 | ||
| # https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
| - name: Get composer cache directory | ||
| id: composer-cache | ||
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: ${{ runner.os }}-composer- | ||
| - name: Validate composer files | ||
| run: | | ||
| composer validate --strict composer.json | ||
| # Check that dependencies resolve. | ||
| composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction | ||
|
|
||
| php-coding-standards: | ||
| name: PHP coding standards | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| php-versions: [ '8.1' ] | ||
| steps: | ||
| - uses: actions/checkout@master | ||
| - name: Setup PHP, with composer and extensions | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-versions }} | ||
| extensions: json | ||
| coverage: none | ||
| tools: composer:v2 | ||
| # https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
| - name: Get composer cache directory | ||
| id: composer-cache | ||
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: ${{ runner.os }}-composer- | ||
| - name: Install Dependencies | ||
| run: | | ||
| composer install --no-interaction --no-progress | ||
| - name: PHPCS | ||
| run: | | ||
| composer coding-standards-check/phpcs | ||
|
|
||
| php-code-analysis: | ||
| name: PHP code analysis | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| php-versions: [ '8.1' ] | ||
| steps: | ||
| - uses: actions/checkout@master | ||
| - name: Setup PHP, with composer and extensions | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php-versions }} | ||
| extensions: json | ||
| coverage: none | ||
| tools: composer:v2 | ||
| # https://github.com/shivammathur/setup-php#cache-composer-dependencies | ||
| - name: Get composer cache directory | ||
| id: composer-cache | ||
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
| - name: Cache dependencies | ||
| uses: actions/cache@v2 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: ${{ runner.os }}-composer- | ||
| - name: Code analysis | ||
| run: | | ||
| ./scripts/code-analysis | ||
|
|
||
| markdownlint: | ||
| runs-on: ubuntu-latest | ||
| name: markdownlint | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v2 | ||
| - name: Get yarn cache directory path | ||
| id: yarn-cache-dir-path | ||
| run: echo "::set-output name=dir::$(yarn cache dir)" | ||
| - name: Cache yarn packages | ||
| uses: actions/cache@v2 | ||
| id: yarn-cache | ||
| with: | ||
| path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- | ||
| - name: Yarn install | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '20' | ||
| - run: yarn install | ||
| - name: markdownlint | ||
| run: yarn coding-standards-check/markdownlint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| composer.lock | ||
| vendor/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!-- markdownlint-disable MD024 --> | ||
| # Changelog | ||
|
|
||
| All notable changes to this project will be documented in this file. | ||
|
|
||
| The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), | ||
| and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| - First version of the module | ||
|
|
||
| [Unreleased]: https://github.com/OS2web/os2web_audit/compare/develop...HEAD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,49 @@ | ||
| # OS2Form Audit Module | ||
| # OS2Web Audit | ||
|
|
||
| OS2Form Audit is a Drupal module that helps track changes and perform audit on | ||
| OS2Form events. | ||
|
|
||
| ## Requirements | ||
| - | ||
| - PHP 8.1 or higher | ||
| - Drupal 8 or 9 | ||
| - Composer for managing PHP dependencies | ||
| This audit module can be used to track changes and perform audit logging on | ||
| drupal sites. | ||
|
|
||
| ## Features | ||
| - | ||
| - Detailed audit log entries. | ||
| - Support for all OS2Form entity types. | ||
| - Easily extendable for custom use case. | ||
|
|
||
| ## Installation | ||
| This module includes three plugins that facilitate logging information to Loki, | ||
| files, or to the database through Drupal's watchdog logger. | ||
|
|
||
| ### Composer | ||
| These logging providers are designed using Drupal's plugin APIs. Consequently, | ||
| it opens up possibilities for creating new AuditLogger plugins within other | ||
| modules, thus enhancing the functionality of this audit logging. | ||
|
|
||
| ### Drush | ||
| ## Installation | ||
|
|
||
| Enable the module and go to the modules setting page at | ||
| `/admin/config/os2web_audit/settings/`. | ||
|
|
||
| ### Admin UI | ||
| ```shell | ||
| composer require os2web/os2web_audit | ||
| drush pm:enable os2web_audit | ||
| ``` | ||
|
|
||
| Alternatively, you can enable this module via Drupal admin UI by visiting the | ||
| extent page (`/admin/modules`). | ||
| ### Drush | ||
|
|
||
| ## Configuration | ||
| The module provides a Drush command named audit:log. This command enables you | ||
| to log a test message to the configured logger. The audit:log command accepts a | ||
| string that represents the message to be logged. | ||
|
|
||
| Navigate to `/admin/config/os2form/audit` to configure the module. | ||
| The message provided, will be logged twice, once as an informational message | ||
| and once as an error message. | ||
|
|
||
| Some additional (brief) information on Usage, Extending/Overriding, and | ||
| Maintainers could go here. | ||
| ```shell | ||
| drush audit:log 'This is a test message' | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| Describe how to use this module after installation. | ||
| The module exposes a simple `Logger` service which can log an `info` and `error` | ||
| messages. | ||
|
|
||
| ## Extending and Overriding | ||
| Inject the logger service named `os2web_audit.logger` and send messages into the | ||
| logger as shown below: | ||
|
|
||
| Describe how to extend or override this module's functionality. | ||
| ```php | ||
| $msg = sprintf('Fetch personal data from service with parameter: %s', $param); | ||
| $this->auditLogger->info('Lookup', $msg); | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "name": "os2web/os2web_audit", | ||
| "type": "drupal-module", | ||
| "description": "Drupal OS2 module that provides audit logging for Danish Municipalities", | ||
| "minimum-stability": "dev", | ||
| "prefer-stable": true, | ||
| "license": "EUPL-1.2", | ||
| "repositories": { | ||
| "drupal": { | ||
| "type": "composer", | ||
| "url": "https://packages.drupal.org/8" | ||
| }, | ||
| "assets": { | ||
| "type": "composer", | ||
| "url": "https://asset-packagist.org" | ||
| } | ||
| }, | ||
| "require": { | ||
| "ext-curl": "*", | ||
| "php": "^8.1", | ||
| "drush/drush": "^11.6" | ||
| }, | ||
| "require-dev": { | ||
| "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", | ||
| "drupal/coder": "^8.3", | ||
| "mglaman/phpstan-drupal": "^1.1", | ||
| "phpstan/extension-installer": "^1.3", | ||
| "phpstan/phpstan-deprecation-rules": "^1.1", | ||
| "phpunit/phpunit": "^9.5" | ||
| }, | ||
| "extra" : { | ||
| "composer-exit-on-patch-failure": false, | ||
| "enable-patching" : true, | ||
| "patches": { | ||
| } | ||
| }, | ||
| "scripts": { | ||
| "code-analysis/phpstan": [ | ||
| "phpstan analyse" | ||
| ], | ||
| "code-analysis": [ | ||
| "@code-analysis/phpstan" | ||
| ], | ||
| "coding-standards-check/phpcs": [ | ||
| "phpcs --standard=phpcs.xml.dist" | ||
| ], | ||
| "coding-standards-check": [ | ||
| "@coding-standards-check/phpcs" | ||
| ], | ||
| "coding-standards-apply/phpcs": [ | ||
| "phpcbf --standard=phpcs.xml.dist" | ||
| ], | ||
| "coding-standards-apply": [ | ||
| "@coding-standards-apply/phpcs" | ||
| ] | ||
| }, | ||
| "config": { | ||
| "sort-packages": true, | ||
| "allow-plugins": { | ||
| "phpstan/extension-installer": true, | ||
| "dealerdirect/phpcodesniffer-composer-installer": true | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| name: "OS2web Audit" | ||
| description: 'OS2web Audit Module (log events in the system)' | ||
| type: module | ||
| core_version_requirement: ^8 || ^9 || ^10 | ||
| configure: os2web_audit.plugin_settings_local_tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| os2web_audit.admin_settings: | ||
| title: 'OS2web Audit settings' | ||
| parent: system.admin_config_system | ||
| description: 'Settings for the OS2 Audit module' | ||
| route_name: os2web_audit.plugin_settings_local_tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| os2web_audit.plugin_settings_tasks: | ||
| title: 'OS2web Audit settings' | ||
| route_name: os2web_audit.plugin_settings_local_tasks | ||
| base_route: os2web_audit.plugin_settings_local_tasks | ||
| deriver: Drupal\os2web_audit\Plugin\Derivative\LocalTask |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| os2web_audit.plugin_settings_local_tasks: | ||
| path: '/admin/config/os2web_audit/settings/{type}' | ||
| defaults: | ||
| _controller: '\Drupal\os2web_audit\Controller\LocalTasksController::dynamicTasks' | ||
| _title: 'OS2web Audit settings' | ||
| type: '' | ||
| requirements: | ||
| _permission: 'administer site' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| services: | ||
| plugin.manager.os2web_audit_logger: | ||
| class: Drupal\os2web_audit\Plugin\LoggerManager | ||
| parent: default_plugin_manager | ||
|
|
||
| os2web_audit.logger: | ||
| class: Drupal\os2web_audit\Service\Logger | ||
| arguments: ['@plugin.manager.os2web_audit_logger', '@config.factory', '@current_user', '@logger.factory'] | ||
|
|
||
| os2web_audit.commands: | ||
| class: Drupal\os2web_audit\Commands\AuditLogDrushCommands | ||
| arguments: ['@os2web_audit.logger'] | ||
| tags: | ||
| - { name: drush.command } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "license": "UNLICENSED", | ||
| "private": true, | ||
| "devDependencies": { | ||
| "markdownlint-cli": "^0.32.2" | ||
| }, | ||
| "scripts": { | ||
| "coding-standards-check/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md'", | ||
| "coding-standards-check": "yarn coding-standards-check/markdownlint", | ||
| "coding-standards-apply/markdownlint": "yarn markdownlint --ignore LICENSE.md --ignore vendor --ignore node_modules '*.md' 'modules/os2forms_digital_post/**/*.md' --fix", | ||
| "coding-standards-apply": "yarn coding-standards-apply/markdownlint" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ruleset name="PHP_CodeSniffer"> | ||
| <description>OS2web Audit PHP Code Sniffer configuration</description> | ||
|
|
||
| <file>.</file> | ||
| <exclude-pattern>vendor/</exclude-pattern> | ||
| <exclude-pattern>node_modules/</exclude-pattern> | ||
|
|
||
| <!-- Show progress of the run --> | ||
| <arg value="p"/> | ||
|
|
||
| <arg name="extensions" value="php,module,inc,install,test,profile,theme,css,info,txt,yml"/> | ||
| <config name="drupal_core_version" value="9"/> | ||
|
|
||
|
|
||
| <rule ref="Drupal"> | ||
| <!-- We want to be able to use "package" and "version" in our custom modules --> | ||
| <exclude name="Drupal.InfoFiles.AutoAddedKeys.Project"/> | ||
| <exclude name="Drupal.InfoFiles.AutoAddedKeys.Version"/> | ||
| </rule> | ||
|
|
||
| <rule ref="DrupalPractice"/> | ||
| </ruleset> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.