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

feat: Add Wordpress cataloger #2218

Merged
merged 17 commits into from Feb 14, 2024
Merged

Conversation

disc
Copy link
Contributor

@disc disc commented Oct 11, 2023

Add a cataloger that detects installed Wordpress plugins by looking files in */wp-content/plugins/* directories
Closes #1911

Related MR to Grype for removing wordpress from known targets and unsuppressing of wordpress plugins vulnerabilities
anchore/grype#1553

@disc disc force-pushed the wordpress-plugins-cataloger branch from 05b6371 to ac62058 Compare October 11, 2023 16:22
disc added a commit to disc/grype that referenced this pull request Oct 11, 2023
disc added a commit to disc/grype that referenced this pull request Oct 11, 2023
…upport (anchore/syft#2218) in `Syft`

Signed-off-by: disc <a.hacicheant@gmail.com>
@wagoodman wagoodman self-assigned this Oct 11, 2023
@disc disc force-pushed the wordpress-plugins-cataloger branch 6 times, most recently from 4fe47a9 to 74382e7 Compare October 12, 2023 17:41
@github-actions github-actions bot added the json-schema Changes the json schema label Nov 21, 2023
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

@disc I've caught up this branch based on the several changes made on main recently. I have a couple of small questions, otherwise I feel this is about the cross the finish line 🙌

@disc disc requested a review from wagoodman November 22, 2023 15:33
@wagoodman wagoodman added the enhancement New feature or request label Feb 2, 2024
@wagoodman wagoodman changed the title feat: Add Wordpress cataloger Add Wordpress cataloger Feb 2, 2024
@wagoodman wagoodman removed the enhancement New feature or request label Feb 2, 2024
@wagoodman wagoodman changed the title Add Wordpress cataloger feat: Add Wordpress cataloger Feb 2, 2024
wagoodman
wagoodman previously approved these changes Feb 2, 2024
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

Thanks for adding this cataloger 🙌 ! (and thanks for your patience on this PR -- it came in the midst of an API refactor so needed to land afterwards).

@wagoodman wagoodman enabled auto-merge (squash) February 2, 2024 19:05
@wagoodman
Copy link
Contributor

wagoodman commented Feb 2, 2024

@disc A couple of clarifying questions:

{
  "id": "62595455b80ed7ff",
  "name": "Akismet Anti-spam: Spam Protection",
  "version": "5.3",
  "type": "wordpress-plugin",
  "foundBy": "wordpress-plugin-cataloger",
  ...  
  "metadata": {
    "plugin_name": "akismet",
    "author": "Automattic - Anti-spam Team",
    "author_uri": "https://automattic.com/wordpress-plugins/"
  }
}
  1. Should the pkg.Package.Name be what is currently the pkg.WordpressPlugin.PluginName? (I could reason either way, curious for opinions here)
  2. (Completely independent from the first question) Should pkg.WordpressPlugin.PluginName really be something like pkg.WordpressPlugin.PluginInstallDirectory (or similar) since it's derived from an installation path?

(I can make the updates if there are any changes needed)

@disc disc force-pushed the wordpress-plugins-cataloger branch from e63cc96 to c314462 Compare February 3, 2024 16:41
Copy link

github-actions bot commented Feb 3, 2024

Warning

Detected modification or removal of existing json schemas:

  • schema/json/schema-16.0.2.json

@disc
Copy link
Contributor Author

disc commented Feb 3, 2024

@disc A couple of clarifying questions:

{
  "id": "62595455b80ed7ff",
  "name": "Akismet Anti-spam: Spam Protection",
  "version": "5.3",
  "type": "wordpress-plugin",
  "foundBy": "wordpress-plugin-cataloger",
  ...  
  "metadata": {
    "plugin_name": "akismet",
    "author": "Automattic - Anti-spam Team",
    "author_uri": "https://automattic.com/wordpress-plugins/"
  }
}
1. Should the `pkg.Package.Name` be what is currently the `pkg.WordpressPlugin.PluginName`? (I could reason either way, curious for opinions here)

2. (Completely independent from the first question) Should `pkg.WordpressPlugin.PluginName` really be something like `pkg.WordpressPlugin.PluginInstallDirectory` (or similar) since it's derived from an installation path?

(I can make the updates if there are any changes needed)

Hey @wagoodman. Looks like I need to make a few changes after a huge refactor and probably these questions won't be actual further.

@wagoodman
Copy link
Contributor

I can help with restoring/regenerating the JSON schema if needed. Also, is the refactor you're referring to one that happened on main (touching the cataloging API)? Or are you talking about a refactor within the new wordpress plugin cataloger you wrote?

@disc
Copy link
Contributor Author

disc commented Feb 7, 2024

is the refactor you're referring to one that happened on main (touching the cataloging API)?

Yes, I meant this one. I've just completed all the needed changes - now need to look into a test run.

@disc disc force-pushed the wordpress-plugins-cataloger branch from 9e68763 to abe03cb Compare February 7, 2024 18:19
@wagoodman wagoodman dismissed their stale review February 9, 2024 16:37

rereviewing due to changes

@wagoodman
Copy link
Contributor

Hey, I fixed the failing tests and updated the branch. I still have some questions left (from #2218 (comment))

  1. Should the value in pkg.Package.Name really be what is currently in the pkg.WordpressPlugin.PluginName field? Said another way, should the package name be the install directory name instead of the plugin display name?
  2. Should pkg.WordpressPlugin.PluginName really be renamed to pkg.WordpressPlugin.PluginInstallDirectory (or similar) since it's derived from an installation path and not actually the Plugin Name: field from the underlying source code?

@disc
Copy link
Contributor Author

disc commented Feb 9, 2024

Hey, I fixed the failing tests and updated the branch. I still have some questions left (from #2218 (comment))

1. Should the value in `pkg.Package.Name` really be what is currently in the `pkg.WordpressPlugin.PluginName` field? Said another way, should the package name be the install directory name instead of the plugin display name?

2. Should `pkg.WordpressPlugin.PluginName` really be renamed to `pkg.WordpressPlugin.PluginInstallDirectory` (or similar) since it's derived from an installation path and not actually the `Plugin Name:` field from the underlying source code?
  1. I believe yes, it makes the package name short and simple, sometimes it contains long names such as Akismet Anti-spam: Spam Protection
  2. Probably yes, it's contains almost the same as a name but uses for building CPEs

@wagoodman
Copy link
Contributor

It sounds like both answers point to making some small updates -- I can take a stab at it if you'd like? (or if you wanted to that's also alright)

disc and others added 16 commits February 14, 2024 10:49
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Added integration test for `wordpress-plugin`

Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

I force pushed a rebase (there were a few commits from main that didn't belong). I also regenerated the JSON schema after changing the field caps to be consistent with the field convention we use (camel case).

Overall great work -- thanks for taking the time to add this cataloger 🙏 !

@wagoodman wagoodman enabled auto-merge (squash) February 14, 2024 15:57
@wagoodman wagoodman merged commit 96ee2db into anchore:main Feb 14, 2024
11 checks passed
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* Closes anchore#1911 Wordpress cataloger

Signed-off-by: disc <a.hacicheant@gmail.com>

* Fixed a few unit tests and static analizer notices

Signed-off-by: disc <a.hacicheant@gmail.com>

* Updated `README.md`

Signed-off-by: disc <a.hacicheant@gmail.com>

* Fixed `golangci-lint` notices
Added integration test for `wordpress-plugin`

Signed-off-by: disc <a.hacicheant@gmail.com>

* Fixed `gosimports` notices

Signed-off-by: disc <a.hacicheant@gmail.com>

* Updated `json schema` version

Signed-off-by: disc <a.hacicheant@gmail.com>

* Fixed CLI tests, increased expected package count

Signed-off-by: disc <a.hacicheant@gmail.com>

* Read first 4Kb of a plugins file's content

Signed-off-by: disc <a.hacicheant@gmail.com>

* replace JSON schema version

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* change wording on source info for wordpress packages

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* Minor changes after a huge refactoring

Signed-off-by: disc <a.hacicheant@gmail.com>

* Removed unused files

Signed-off-by: disc <a.hacicheant@gmail.com>

* Updated schema

Signed-off-by: disc <a.hacicheant@gmail.com>

* Fixed integration tests

Signed-off-by: disc <a.hacicheant@gmail.com>

* fix integration tests

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

* Renamed `metadata.Name` to `metadata.PluginInstallDirectory`

Signed-off-by: disc <a.hacicheant@gmail.com>

* rename fields to be compliant with json conventions

Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>

---------

Signed-off-by: disc <a.hacicheant@gmail.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
json-schema Changes the json schema
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Catalog wordpress plugins
2 participants