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

Add lua/rockspec cataloger #2613

Merged
merged 1 commit into from May 24, 2024
Merged

Add lua/rockspec cataloger #2613

merged 1 commit into from May 24, 2024

Conversation

LaurentGoderre
Copy link
Contributor

No description provided.

@LaurentGoderre LaurentGoderre marked this pull request as ready for review February 16, 2024 19:07
@LaurentGoderre LaurentGoderre changed the title Add lua/rockspec cataloguer Add lua/rockspec cataloger Feb 16, 2024
@LaurentGoderre
Copy link
Contributor Author

Depends on anchore/packageurl-go#18

This comment has been minimized.

@LaurentGoderre LaurentGoderre force-pushed the lua-lang branch 5 times, most recently from a9cdb1b to afda7a1 Compare March 13, 2024 17:47
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Sorry for the delay here, @LaurentGoderre. I left some feedback inline. I'll also note that this can be rebased to get rid of some duplicate changes from the packageurl lib upgrade. That said, one thing I'd like to make sure about is in fact, the luarock string in the packageurl that doesn't seem to match the notes in the spec types of just lua. EDIT: I see the discussion here about it, so luarock seems to be fine.

@@ -109,6 +110,7 @@ func DefaultPackageTaskFactories() PackageTaskFactories {
),
newSimplePackageTaskFactory(java.NewNativeImageCataloger, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, pkgcataloging.LanguageTag, "java"),
newSimplePackageTaskFactory(nix.NewStoreCataloger, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, pkgcataloging.LanguageTag, "nix"),
newSimplePackageTaskFactory(lua.NewPackageCataloger, pkgcataloging.DirectoryTag, pkgcataloging.InstalledTag, pkgcataloging.ImageTag, pkgcataloging.LanguageTag, "lua"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it typical to find lua rockspec files in images (and "installed")?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know about typical but the image that prompted this changed (Kong DOI) has them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed it does

root@9568d1a22c40:/# find / | grep rockspec | grep cjson
root@9568d1a22c40:/# luarocks install lua-cjson

Installing https://luarocks.org/lua-cjson-2.1.0.10-1.src.rock
lua-cjson 2.1.0.10-1 depends on lua >= 5.1 (5.4-1 provided by VM: success)
gcc -O2 -fPIC -I/usr/local/include -c lua_cjson.c -o lua_cjson.o
gcc -O2 -fPIC -I/usr/local/include -c strbuf.c -o strbuf.o
gcc -O2 -fPIC -I/usr/local/include -c fpconv.c -o fpconv.o
gcc  -shared -o /tmp/luarocks_build-lua-cjson-2.1.0.10-1-2704986/cjson.so lua_cjson.o strbuf.o fpconv.o
lua-cjson 2.1.0.10-1 is now installed in /usr/local (license: MIT)

root@9568d1a22c40:/# find / | grep rockspec | grep cjson
/usr/local/lib/luarocks/rocks-5.4/lua-cjson/2.1.0.10-1/lua-cjson-2.1.0.10-1.rockspec

I don't know if it's actively needed at runtime or if it is metadata that could be scrubbed and the lib still used. But the luarocks install command will leave rockspecs behind 👍 .

syft/pkg/cataloger/lua/package.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/package.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/package_test.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/package.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/parse_rockspec.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/parse_rockspec.go Outdated Show resolved Hide resolved
syft/pkg/type.go Outdated Show resolved Hide resolved
syft/pkg/rockspec.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved

This comment has been minimized.

@LaurentGoderre LaurentGoderre force-pushed the lua-lang branch 4 times, most recently from c71f8f0 to cd4cac9 Compare April 9, 2024 13:46
Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

Thanks @LaurentGoderre -- there are a few more spots I think we need guards to protect against malformed input causing panics, basically after every SkipWhitespace, it's possible that malformed input could result in a panic. I think I've noted each of the spots this could happen. Other than those small changes, this looks great! 👍

syft/internal/packagemetadata/names.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Outdated Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved
tests := []struct {
name string
content string
wantErr require.ErrorAssertionFunc
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice if these tests were asserting a specific return structure instead of just asserting that they don't result in errors. this could help when expanding the parser, but don't consider it blocking since I know there's a follow-on enhancement you have planned here, it could be done then.

syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved
syft/pkg/cataloger/lua/rockspec_parser.go Show resolved Hide resolved
@LaurentGoderre LaurentGoderre force-pushed the lua-lang branch 3 times, most recently from f00ddc5 to 0afc048 Compare May 24, 2024 17:04
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
@LaurentGoderre
Copy link
Contributor Author

@kzantow done!

Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

LGTM thanks for the contribution @LaurentGoderre ! 🎉

@kzantow kzantow merged commit b51252d into anchore:main May 24, 2024
11 checks passed
@LaurentGoderre LaurentGoderre deleted the lua-lang branch May 24, 2024 21:23
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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants