importmap-rails icon indicating copy to clipboard operation
importmap-rails copied to clipboard

bin/importmap verify compares vendored files with remotes

Open martinemde opened this issue 1 year ago • 4 comments

In rubygems/rubygems.org#4396 we ran into the problem of verifying the provenance of files in vendor/javascript. This is a blocker for us using importmap-rails at this time.

In this PR, I attempted to add a process that could be run in CI that would download and verify that the files that are vendored are actually what would be downloaded fresh today.

I assume there are some edge-cases, or even really obvious cases, that I didn't handle in this PR. I wanted to start gathering feedback so I know if this is the right solution.

martinemde avatar Jan 27 '24 03:01 martinemde

Heads up - PR will conflict with https://github.com/rails/importmap-rails/pull/235.

I'm happy to resolve the conflicts despite which may get merged first

Caleb-T-Owens avatar Jan 27 '24 22:01 Caleb-T-Owens

@Caleb-T-Owens Thanks! I'd be happy to work with you on it assuming this PR is accepted.

martinemde avatar Jan 28 '24 02:01 martinemde

For reference, here is our importmap.rake where I implemented this verify step in rubygems.org.

Current output:

$ rake importmap:verify
Verifying packages in vendor/javascript
Verifying "@rails/ujs" download from https://ga.jspm.io/npm:@rails/[email protected]/app/assets/javascripts/rails-ujs.esm.js
Verified  "@rails/ujs" at vendor/javascript/@rails--ujs.js
Verifying "clipboard" download from https://ga.jspm.io/npm:[email protected]/dist/clipboard.js
Verified  "clipboard" at vendor/javascript/clipboard.js
Verifying "jquery" download from https://ga.jspm.io/npm:[email protected]/dist/jquery.js
Verified  "jquery" at vendor/javascript/jquery.js
Verifying "stimulus-rails-nested-form" download from https://ga.jspm.io/npm:[email protected]/dist/stimulus-rails-nested-form.mjs
Verified  "stimulus-rails-nested-form" at vendor/javascript/stimulus-rails-nested-form.js
Verifying "@hotwired/stimulus" download from https://ga.jspm.io/npm:@hotwired/[email protected]/dist/stimulus.js
Verified  "@hotwired/stimulus" at vendor/javascript/@hotwired--stimulus.js
All pinned js in vendor/javascript verified.

I think the output could be cleaned up a bit.

martinemde avatar Feb 19 '24 20:02 martinemde

Is there anything we can do to move this forward? :thinking:

simi avatar Mar 12 '24 00:03 simi