fix(plugin): clear the adm-zip advisories and the CodeQL maven URL alert - #11
Merged
Merged
Conversation
adm-zip 0.5.17 is the only runtime dependency and carries two advisories. GHSA-xcpc-8h2w-3j85 (high) lets an archive that declares a huge uncompressed size force an unbounded allocation. GHSA-vwc7-r8mq-g2x9 (moderate) lets extraction write through destination symlinks. Neither is reachable from the plugin. It never extracts to disk, and it only parses the AAR it downloaded after checking its SHA-256 against the pin, or its own cached copy under node_modules. Consumers' npm audit still traced both back to this package. 0.6 ships its own types, so @types/adm-zip goes. Its breaking changes (extractEntryTo path handling, Node 14 minimum) touch nothing the plugin calls. The strip was run against the real sdk-pdf-2.1.4.aar on 0.6.1: the result passes unzip -t and classes.jar no longer holds the Glide class.
withDocuSignAndroidMavenRepo skipped adding the repository whenever build.gradle contained its URL as a substring. A commented-out declaration or a longer URL with the same prefix counted as present, so the repository was never added. CodeQL flagged the same line as js/incomplete-url-substring-sanitization. The check guards nothing security related, but the substring match was still wrong. The check now reads build.gradle's string literals, skipping // and /* */ comments, and compares each with the repository URL, trailing slashes removed. Comments and strings are matched in one pass, so a glob such as 'libs/*' is not mistaken for the start of a comment, and backslash escapes are honoured, so an escaped quote does not end a string early. Quote style, uri(), trailing comments and multi-line maven blocks still count as declared. The plugin had no tests. Jest now picks up plugin/src, and plugin/tsconfig.build.json excludes *.test.ts so tests stay out of the published plugin/build. Coverage now includes the plugin and reports 49% for plugin/src/index.ts, because the AAR download and strip remain untested. No threshold is set for it.
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.
Fixes the two findings from a review of the Security tab: CodeQL alert #1 on the Config Plugin's maven repository check, and the
adm-zipadvisories that appear innpm auditbut not on the tab, because Dependabot alerts are off.Why
adm-zip@0.5.17, the only runtime dependency, has GHSA-xcpc-8h2w-3j85 (high, a crafted archive forces an unbounded allocation) and GHSA-vwc7-r8mq-g2x9 (moderate, extraction writes through destination symlinks). Neither is reachable. The plugin never extracts to disk, and it only parses the AAR it downloaded after checking its SHA-256, or its own cached copy undernode_modules. Every consumer'snpm auditstill reports both through this package.contents.includes(repo)inwithDocuSignAndroidMavenRepoasjs/incomplete-url-substring-sanitization. The line only prevents a duplicate repository entry, so there is nothing to exploit. The substring match was still wrong: a declaration inside a comment, or a longer URL with the same prefix, counted as present and the repository was never added.Changes
adm-zipgoes from^0.5.17to^0.6.1, and@types/adm-zipis removed because 0.6 ships its own types. The 0.6 breaking changes (extractEntryTopath handling, Node 14 minimum) touch nothing the plugin calls.hasMavenReporeads the string literals inbuild.gradle, skipping//and/* */comments, and compares each with the repository URL, trailing slashes removed. Comments and strings are matched in one pass, so a glob like'libs/*'isn't mistaken for the start of a comment, and backslash escapes are honoured, so"a\"b"doesn't end a string early. Quote style,uri(), trailing comments and multi-linemavenblocks still count as declared.plugin/src/index.test.ts. They run the realprojectBuildGradlemod chain from the default export against samplebuild.gradlecontent, with no mocks.jest.config.jsruns and collects coverage forplugin/src.plugin/tsconfig.build.jsonexcludes*.test.ts, so tests stay out ofplugin/buildand the tarball.plugin/tsconfig.jsonstill includes them, so the IDE type-checks the test file.CHANGELOG.mdentries under## Next.Verification
includes()check, 4 plugin tests fail: line comment, single-line and multi-line block comments, and the longer URL.tsc -p plugin/tsconfig.json(source and test), build, lint, examples type-check and prettier pass.plugin/buildholds onlyindex.js,index.d.tsand the source map.npm audit --omit=devno longer listsadm-zip. 0.6.1 was published by the same npm account as earlier releases, has no dependencies, and matches its GitHub release notes.sdk-pdf-2.1.4.aar, whose hash matchesSDK_PDF_SHA256. The output passesunzip -t,classes.jarno longer holds the Glide class, and 0.6.1's new duplicate entry and data extent checks don't reject the artifact.plugin/tsconfig.json. The second found that an escaped quote earlier on a line hid a declaration, which would have added a duplicatemavenblock. Both are fixed here. The last pass approved it, with the performance note under follow-ups.Not verified
expo prebuildand Android Gradle build in a consuming app. The strip check ran the plugin's exact adm-zip calls against the real artifact, not a full prebuild.Follow-ups
plugin/src/index.tsreads 49%. The AAR download, strip and cache recovery paths have no tests, and the plugin has no coverage threshold, so thetestjob is unaffected. Covering them needsfetchandfsmocks.hasMavenReposearches the whole file, as the old check did, so a matching URL inbuildscript.repositoriesalso stops the injection intoallprojects.\"pairs with no closing quote takes 2s at 100 KB and 8s at 200 KB. A rootbuild.gradleis a few KB, so it stays a regex. A hand-written linear scanner would remove it.Notes
mainafter merge.