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

Update Syft formats for SyftJson #752

Merged
merged 2 commits into from
Jan 18, 2022
Merged

Update Syft formats for SyftJson #752

merged 2 commits into from
Jan 18, 2022

Conversation

Toure
Copy link
Contributor

@Toure Toure commented Jan 18, 2022

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon toure.dunnon@anchore.com

@Toure Toure requested review from wagoodman and spiffcs January 18, 2022 19:28
spiffcs
spiffcs previously approved these changes Jan 18, 2022
@spiffcs spiffcs self-requested a review January 18, 2022 19:31
@github-actions
Copy link

github-actions bot commented Jan 18, 2022

Benchmark Test Results

Benchmark results from the latest changes vs base branch
name                                                       old time/op    new time/op    delta
ImagePackageCatalogers/ruby-gemspec-cataloger-2              1.45ms ± 2%    1.67ms ± 6%  +14.89%  (p=0.008 n=5+5)
ImagePackageCatalogers/python-package-cataloger-2            3.49ms ±11%    3.77ms ± 2%     ~     (p=0.310 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2    1.02ms ± 2%    1.18ms ± 1%  +15.40%  (p=0.008 n=5+5)
ImagePackageCatalogers/javascript-package-cataloger-2         912µs ± 2%    1032µs ± 2%  +13.18%  (p=0.008 n=5+5)
ImagePackageCatalogers/dpkgdb-cataloger-2                    1.06ms ± 3%    1.19ms ± 1%  +12.17%  (p=0.008 n=5+5)
ImagePackageCatalogers/rpmdb-cataloger-2                      980µs ± 2%    1065µs ± 2%   +8.76%  (p=0.008 n=5+5)
ImagePackageCatalogers/java-cataloger-2                      15.8ms ± 7%    17.1ms ± 2%     ~     (p=0.056 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                     1.44ms ±10%    1.55ms ± 3%     ~     (p=0.310 n=5+5)
ImagePackageCatalogers/go-module-binary-cataloger-2          1.91µs ± 1%    2.33µs ± 2%  +21.66%  (p=0.008 n=5+5)

name                                                       old alloc/op   new alloc/op   delta
ImagePackageCatalogers/ruby-gemspec-cataloger-2               253kB ± 0%     253kB ± 0%   -0.23%  (p=0.032 n=5+5)
ImagePackageCatalogers/python-package-cataloger-2            1.07MB ± 0%    1.06MB ± 0%     ~     (p=0.548 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2     230kB ± 0%     230kB ± 0%     ~     (p=0.310 n=5+5)
ImagePackageCatalogers/javascript-package-cataloger-2         208kB ± 0%     207kB ± 0%     ~     (p=0.056 n=5+5)
ImagePackageCatalogers/dpkgdb-cataloger-2                     254kB ± 0%     253kB ± 0%   -0.32%  (p=0.008 n=5+5)
ImagePackageCatalogers/rpmdb-cataloger-2                      235kB ± 0%     235kB ± 0%     ~     (p=0.151 n=5+5)
ImagePackageCatalogers/java-cataloger-2                      3.78MB ± 0%    3.78MB ± 0%   -0.20%  (p=0.008 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                     1.30MB ± 0%    1.30MB ± 0%   -0.04%  (p=0.032 n=5+5)
ImagePackageCatalogers/go-module-binary-cataloger-2            560B ± 0%      560B ± 0%     ~     (all equal)

name                                                       old allocs/op  new allocs/op  delta
ImagePackageCatalogers/ruby-gemspec-cataloger-2               6.33k ± 0%     6.33k ± 0%     ~     (all equal)
ImagePackageCatalogers/python-package-cataloger-2             21.4k ± 0%     21.4k ± 0%     ~     (p=0.444 n=5+5)
ImagePackageCatalogers/php-composer-installed-cataloger-2     6.06k ± 0%     6.06k ± 0%   -0.02%  (p=0.016 n=4+5)
ImagePackageCatalogers/javascript-package-cataloger-2         5.34k ± 0%     5.34k ± 0%     ~     (all equal)
ImagePackageCatalogers/dpkgdb-cataloger-2                     7.07k ± 0%     7.07k ± 0%     ~     (all equal)
ImagePackageCatalogers/rpmdb-cataloger-2                      6.80k ± 0%     6.80k ± 0%     ~     (all equal)
ImagePackageCatalogers/java-cataloger-2                       74.7k ± 0%     74.7k ± 0%     ~     (p=0.302 n=5+5)
ImagePackageCatalogers/apkdb-cataloger-2                      7.36k ± 0%     7.36k ± 0%     ~     (all equal)
ImagePackageCatalogers/go-module-binary-cataloger-2            13.0 ± 0%      13.0 ± 0%     ~     (all equal)

@spiffcs spiffcs dismissed their stale review January 18, 2022 19:31

misclick

@spiffcs
Copy link
Contributor

spiffcs commented Jan 18, 2022

@Toure is there more context for this change or a reference for why we need to have these values omitted?

In what cases are you seeing these show up as null on the JSON output?

There are also some cases (should we make this change) that need to be updated on the CLI test side

@Toure Toure requested a review from Vijay-P January 18, 2022 19:34
@Vijay-P
Copy link
Contributor

Vijay-P commented Jan 18, 2022

        {
            "id": "2666e846-97b0-4f6a-8701-f0bd19ac5e83",
            "name": "Authlib",
            "version": "0.15.2",
            "type": "python",
            "foundBy": "python-index-cataloger",
            "locations": [
                {
                    "path": "/Users/vijay/Documents/enterprise/requirements-test.txt"
                }
            ],
            "licenses": [],
            "language": "python",
            "cpes": [
                "cpe:2.3:a:python_Authlib:python-Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python_Authlib:python_Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python-Authlib:python-Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python-Authlib:python_Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python-Authlib:Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:Authlib:python-Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:Authlib:python_Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python_Authlib:Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python:python_Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python:python-Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:Authlib:Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python:Authlib:0.15.2:*:*:*:*:python:*:*",
                "cpe:2.3:a:python-Authlib:python-Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python_Authlib:python_Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python-Authlib:python_Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python_Authlib:python-Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python_Authlib:Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:Authlib:python-Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python-Authlib:Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:Authlib:python_Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python:python_Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python:python-Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:Authlib:Authlib:0.15.2:*:*:*:*:*:*:*",
                "cpe:2.3:a:python:Authlib:0.15.2:*:*:*:*:*:*:*"
            ],
            "purl": "pkg:pypi/Authlib@0.15.2",
            "metadataType": "",
            "metadata": null
        },

@Toure
Copy link
Contributor Author

Toure commented Jan 18, 2022

@spiffcs
When scanning Anchore Enterprise the output SBoM will contain a null value for metadata and metadataType attribute, as an example, Python_Authlib returns a null value for metadata which causes document imports to fail, this change would allow us to omit those fields.

@spiffcs
Copy link
Contributor

spiffcs commented Jan 18, 2022

Nice thanks for the example and comments! I think it's fine to drop the metadata field specifically since it would always be a nulll type and not something like "" or 0.

I will defer approval in this case to @wagoodman because maybe he has context or a good reason why we might want to update the UnMarshalJSON function to account for "metadataType": "", and set a value for metadata rather than drop the field completely from the output.

I do think metadataType: "" is useful and in this case dropping the field might not be what we're looking for in the final JSON output.

Copy link
Contributor

@spiffcs spiffcs left a comment

Choose a reason for hiding this comment

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

I'll sync with the tools team about the above comments. I might just be being too careful here about dropping fields from the output if empty.

@spiffcs
Copy link
Contributor

spiffcs commented Jan 18, 2022

The CLI tests are still failing - so those will need a quick update to reflect the new desired output.

@wagoodman
Copy link
Contributor

wagoodman commented Jan 18, 2022

@Toure I can help with the json schema update if you'd like (where CLI tests are failing)

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
@Toure Toure force-pushed the PackageCustomData_update branch from 5a16025 to c8299f3 Compare January 18, 2022 20:23
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
@Toure Toure force-pushed the PackageCustomData_update branch from 8050502 to af54e00 Compare January 18, 2022 21:52
@wagoodman wagoodman merged commit 814f2bf into main Jan 18, 2022
@wagoodman wagoodman deleted the PackageCustomData_update branch January 18, 2022 22:18
spiffcs added a commit that referenced this pull request Jan 19, 2022
…hub.com/hectorj2f/syft into hectorj2f/add_dependencies_to_cyclonedx

* 'hectorj2f/add_dependencies_to_cyclonedx' of https://github.com/hectorj2f/syft: (29 commits)
  Improve CycloneDX format output (#710)
  Add additional PHP metadata (#753)
  Update Syft formats for SyftJson (#752)
  Add support for "file" source type in syftjson unmarshaling (#750)
  remove contains file from spdx dependency generation
  support .sar for java ecosystem (#748)
  Start developer documentation (#746)
  Align SPDX export more with SPDX 2.2 specification (#743)
  Replace distro type (#742)
  update goreleaser with windows checksums (#740)
  bump stereoscope version to remove old containerd (#741)
  Add support for multiple output files in different formats (#732)
  Add support for searching for jars within archives (#734)
  683 windows filepath (#735)
  Fix CPE encode/decode when it contains special chars (#714)
  support .par for java ecosystems (#727)
  Add arm64 support to install script (#729)
  Revert "bump goreleaser to v1.2 (#720)" (#731)
  Add a version flag (#722)
  Add lpkg as java package format (#694)
  ...
fengshunli pushed a commit to fengshunli/syft that referenced this pull request Jan 24, 2022
* Update Syft formats for SyftJson

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>

* Updated the golden files for syftjson to allow for proper
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
Signed-off-by: fsl <1171313930@qq.com>
spiffcs pushed a commit that referenced this pull request Jan 24, 2022
* Update Syft formats for SyftJson

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>

* Updated the golden files for syftjson to allow for proper
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
Signed-off-by: Christopher Phillips <christopher.phillips@anchore.com>
spiffcs pushed a commit that referenced this pull request Jan 25, 2022
* Update Syft formats for SyftJson

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>

* Updated the golden files for syftjson to allow for proper
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
jonasagx pushed a commit to jonasagx/syft that referenced this pull request Jan 28, 2022
* Update Syft formats for SyftJson

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>

* Updated the golden files for syftjson to allow for proper
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* Update Syft formats for SyftJson

This change will introduce omitempty struct tag to PackageCustomData.
This struct tag will cause null and empty values to be dropped on serialization
for consumers downstream.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>

* Updated the golden files for syftjson to allow for proper
test coverage.

Signed-off-by: Toure Dunnon <toure.dunnon@anchore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants