Skip to content
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

Introduce custom file extensions with scanners #320

Merged
merged 88 commits into from
Nov 1, 2022

Conversation

gudmdharalds
Copy link
Contributor

@gudmdharalds gudmdharalds commented Oct 21, 2022

This pull request introduces support for configuring custom file extensions for different scanners.

This resolves #188.

TODO:

  • Specify parameters to make custom file extensions configurable for each scanner type
    • Parameter --autoapprove-php-nonfunctional-changes-file-extensions
    • Parameter --lint-file-extensions
    • Parameter --svg-file-extensions
    • Parameter --phpcs-file-extensions
    • Parameter --wpscan-plugin-api-file-extensions
    • Parameter --wpscan-theme-api-file-extensions
  • Update --help message
    • Add parameters above to the message
  • Update vipgoci_option_array_handle() function so that it can use array as a list of forbidden values as well as a string.
  • Implement logic for custom file extensions
    • Non-functional changes
    • PHP linting
    • SVG file extensions
    • PHPCS
    • WPScan API
  • Add to, or update, Scan run detail report as applicable
  • Add/update tests
    • Update tests/unit/MainRunInitOptionsWpscanTest.php
    • Update tests/unit/MainRunInitOptionsLintTest.php
    • Update tests/unit/MainRunInitOptionsAutoapproveTest.php
    • Update tests/unit/OptionsArrayHandleTest.php
    • Update tests/integration/ApNonfunctionalChangesTest.php
    • Update tests/integration/ApSvgFilesTest.php
    • Update tests/integration/LintScanCommitTest.php
    • Update tests/integration/PhpcsScanScanCommitTest.php
    • Update tests/integration/SvgScanScanCommitTest.php
    • Update tests/integration/WpCoreMiscGetAddonDataAndSlugsForDirectoryTest.php
    • Update tests/integration/WpCoreMiscScanDirectoryForAdddonsTest.php
    • Update tests/integration/MainRunInitOptionsSvgTest.php
    • Update tests/integration/MainRunInitOptionsPhpcsTest.php
    • Update tests/integration/SvgScanScanSingleFileTest.php
    • Update tests/unit/ReportCreateScanDetailsAutoApproveConfigurationTest.php
    • Update tests/unit/ReportCreateScanDetailsPhpLintOptionsTest.php
    • Update tests/unit/ReportCreateScanDetailsPhpcsConfigurationTest.php
    • Update tests/unit/ReportCreateScanDetailsSvgConfigurationTest.php
    • Update tests/unit/ReportCreateScanDetailsWpscanConfigurationTest.php
  • Ensure PHPDoc comments are up to date for functions added or altered
  • Update README
  • Changelog entry (for VIP) [ Changelog for version 1.3.3 #312 ]
  • Public documentation changes
  • Check status of automated tests

Copy link
Collaborator

@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot left a comment

Choose a reason for hiding this comment

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

Code analysis identified issues

VIP Code Analysis Bot has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 1 error


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.


Scan run detail

Software versions

  • vip-go-ci version: 1.3.2
  • PHP runtime version for vip-go-ci: 8.1.11
  • PHP runtime for linting:
    • PHP 8.1: 8.1.11
  • PHP runtime version for PHPCS: 7.4.32
  • PHPCS version: 3.7.1
  • PHP runtime version for SVG scanner: 7.4.32

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • tests/unit

WPScan API configuration

WPScan API scanning enabled: false

wp-core-misc.php Outdated Show resolved Hide resolved
@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot dismissed their stale review October 26, 2022 16:14

Dismissing review as all inline comments are obsolete by now

Copy link
Collaborator

@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot left a comment

Choose a reason for hiding this comment

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

Code analysis identified issues

VIP Code Analysis Bot has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 1 error


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.


Scan run detail

Software versions

  • vip-go-ci version: 1.3.2
  • PHP runtime version for vip-go-ci: 8.1.11
  • PHP runtime for linting:
    • PHP 8.1: 8.1.11
  • PHP runtime version for PHPCS: 7.4.32
  • PHPCS version: 3.7.1
  • PHP runtime version for SVG scanner: 7.4.32

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • tests/unit

WPScan API configuration

WPScan API scanning enabled: false

main.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@wpcomvip-vipgoci-bot wpcomvip-vipgoci-bot left a comment

Choose a reason for hiding this comment

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

Code analysis identified issues

VIP Code Analysis Bot has identified potential problems in this pull request during automated scanning. We recommend reviewing the issues noted and that they are resolved.

phpcs scanning turned up:

🚫 1 error


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.


Scan run detail

Software versions

  • vip-go-ci version: 1.3.2
  • PHP runtime version for vip-go-ci: 8.1.11
  • PHP runtime for linting:
    • PHP 8.1: 8.1.11
  • PHP runtime version for PHPCS: 7.4.32
  • PHPCS version: 3.7.1
  • PHP runtime version for SVG scanner: 7.4.32

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • tests/unit

WPScan API configuration

WPScan API scanning enabled: false

main.php Outdated Show resolved Hide resolved
@wpcomvip-vipgoci-bot
Copy link
Collaborator

No issues were found to report when scanning latest commit (commit-ID: e80b43a)


This bot provides automated PHP linting and PHPCS scanning. For more information about the bot and available customizations, see our documentation.



Scan run detail

Software versions

  • vip-go-ci version: 1.3.2
  • PHP runtime version for vip-go-ci: 8.1.12
  • PHP runtime for linting:
    • PHP 8.1: 8.1.12
  • PHP runtime version for PHPCS: 7.4.32
  • PHPCS version: 3.7.1
  • PHP runtime version for SVG scanner: 7.4.32

Options file (.vipgoci_options)

Options file enabled: true

Configurable options:

  • skip-execution
  • skip-draft-prs
  • lint-modified-files-only
  • phpcs
  • phpcs-severity
  • phpcs-sniffs-include
  • phpcs-sniffs-exclude
  • report-no-issues-found
  • review-comments-sort
  • review-comments-include-severity
  • post-generic-pr-support-comments
  • review-comments-sort
  • scan-details-msg-include
  • svg-checks
  • autoapprove
  • autoapprove-php-nonfunctional-changes

Options altered:

  • phpcs-severityset to1
  • phpcs-sniffs-includeset toGeneric.PHP.DisallowShortOpenTag, Squiz.PHP.CommentedOutCode
  • phpcs-sniffs-excludeset toWordPress.Security.EscapeOutput, WordPress.PHP.DevelopmentFunctions, WordPress.WP.AlternativeFunctions, WordPress.PHP.DiscouragedPHPFunctions, WordPress.Files.FileName, Squiz.Commenting.FileComment, Generic.PHP.Syntax
  • skip-draft-prsset to

PHP lint options

PHP lint files enabled: true

Lint modified files only: true

Directories not PHP linted:

  • None

SVG configuration

SVG scanning enabled: true

Auto-approval configuration

Auto-approvals enabled: true

Non-functional changes auto-approved: true

Auto-approved file-types:

  • css
  • csv
  • eot
  • gif
  • gz
  • ico
  • ini
  • jpeg
  • jpg
  • json
  • less
  • map
  • md
  • mdown
  • mo
  • mp4
  • otf
  • pcss
  • pdf
  • po
  • pot
  • png
  • sass
  • scss
  • styl
  • ttf
  • txt
  • woff
  • woff2
  • yml

PHPCS configuration

PHPCS scanning enabled: true

PHPCS severity level: 1

Standard(s) used:

  • PHPCompatibility
  • PHPCompatibilityParagonieRandomCompat
  • PHPCompatibilityParagonieSodiumCompat
  • VariableAnalysis
  • WordPress

Runtime set:

  • testVersion 8.1-

Custom sniffs included:

  • Generic.PHP.DisallowShortOpenTag
  • Squiz.PHP.CommentedOutCode

Custom sniffs excluded:

  • WordPress.Security.EscapeOutput
  • WordPress.PHP.DevelopmentFunctions
  • WordPress.WP.AlternativeFunctions
  • WordPress.PHP.DiscouragedPHPFunctions
  • WordPress.Files.FileName
  • Squiz.Commenting.FileComment
  • Generic.PHP.Syntax

Directories not PHPCS scanned:

  • None

WPScan API configuration

WPScan API scanning enabled: false

@gudmdharalds gudmdharalds merged commit c30aeae into trunk Nov 1, 2022
@gudmdharalds gudmdharalds deleted the add/file-extensions branch November 1, 2022 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow custom extensions with PHP file type
2 participants