Repository navigation
Conversation
… lists it vxc reads a .vxlib in place of the .vx file beside it, and compiles the function bodies in it. The bodies are in the compiler's internal form, with no source positions and no mark for an `unsafe` block. So the checks for trusted code cannot read them, and a package could ship a .vxlib that got past --no-trusted-code and --audit. Now --no-trusted-code refuses each .vxlib of a package that it names, with E5003. A .vxlib is in the package when its module name starts with the package name, or when the file is in the package directory. --audit prints a line for each .vxlib that the program uses, also for the file that --link-interface names. Fixes: #4599
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR sits on #4623 in a stack, and #4623 sits on #4619.
vxc reads a
.vxlibin place of the.vxfile beside it, and compiles the function bodies in it. The bodies are in the compiler's internal form, with no source positions and no mark for anunsafeblock. So--no-trusted-codeand--auditcannot read them, and a package could ship a.vxlibthat got past both.A list of trusted code inside the file would not help, because the author of the file writes the list.
What changed
--no-trusted-code pkgrefuses each.vxlibofpkgwith E5003:A
.vxlibis inpkgwhen its module name starts withpkg::, or when its file is in the folder ofpkg.--auditprints a line for each.vxlibthat the program uses, and for the file that--link-interfacenames.The loader now records the path of each
.vxlibthat it reads.A parallel compile (
-j) already gives each.vxlibto the normal compile, so the check covers it.Tests
no_trusted_code_refuses_the_vxlib_files_of_its_packageinsrc/hir/check/audit.rs.tests/frontend/fail/no_trusted_code_refuses_a_vxlib_and_audit_names_it.vx, with a normal compile and with-j 2.The pre-commit hook passed on this commit, with #4619 and #4600 below it on main.
Decisions to check
outer/inner. Then--no-trusted-code outerrefuses a.vxlibininner. For a.vxfile there, vxc: find the package of a module from the folder of its file #4612 gives onlyinner. So the.vxlibrule refuses more, never less.--no-trusted-codedoes not refuse a--link-interfacefile, because that file has no package.--auditlists it.Fixes #4599