Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[AssetMapper] Add Integrity Hashes to ImportMap (wip)#58722

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

smnandre
Copy link
Member

QA
Branch?7.2
Bug fix?no
New feature?yes
Deprecations?no
IssuesFix#54249
LicenseMIT

-- Opening early to (hopefully) gather feedback and ideas --

This is a basic implementation to support integrity hashes within import maps:

  • Computes a base64-encoded SHA-384 digest in the factory.
  • Renders the integrity attribute for JavaScript files in the import map.

TODO

  • Make the integrity hash optional (e.g., through a constructor argument in the factory)
  • Compute hashes only for certain assets / types / paths ?
  • Expose configuration settings
  • Adapt the FrameworkBundle / DI
  • Determine handling approach for CSS files

Sources

PS: I'm a bit short on time lately... so if anyone wants to help or take over, please feel free!

chadyred, seb-jean, and pierreboissinot reacted with thumbs up emoji
This is a basic implementation to support integrity hashes within import maps:- Computes a base64-encoded SHA-384 digest in the factory.- Renders the integrity attribute for JavaScript files in the import map.**TODO**- [ ] Make the integrity hash optional (e.g., through a constructor argument in the factory)- [ ] Compute hashes only for certain assets / types / paths ?- [ ] Expose configuration settings- [ ] Adapt the FrameworkBundle / DI- [ ] Determine handling approach for CSS files**Sources**- [Subresource Integrity (SRI) Goals - W3C](https://www.w3.org/TR/SRI/#goals)- [JSPM: JS Integrity with Import Maps](https://jspm.org/js-integrity-with-import-maps)_PS: I'm a bit short on time lately... so if anyone wants to help or take over, please feel free!_
@pierreboissinot
Copy link

Hi@smnandre ,

I'll be glad to continue to help after the week-end.

smnandre#1

smnandre reacted with thumbs up emoji

@pierreboissinot
Copy link

Hi@smnandre , did you checksmnandre#1 ?

smnandre reacted with laugh emoji

@smnandresmnandreforce-pushed thefeat/asset-mapper-integrity branch from9bd9761 to82b44daCompareNovember 7, 2024 01:39
Copy link
Member

@KocalKocal left a comment

Choose a reason for hiding this comment

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

Such a nice addition 🤩

smnandre reacted with heart emoji
Comment on lines +82 to +86
if (null !== $content) {
return 'sha384-'.base64_encode(hash('sha384', $content, true));
}

return 'sha384-'.base64_encode(hash_file('sha384', $asset->sourcePath, true));
Copy link
Member

Choose a reason for hiding this comment

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

Could be simplified to:

Suggested change
if (null !==$content) {
return'sha384-'.base64_encode(hash('sha384',$content,true));
}
return'sha384-'.base64_encode(hash_file('sha384',$asset->sourcePath,true));
$hash =$content !==null ?hash('sha384',$content,true) :hash_file('sha384',$asset->sourcePath,true);
return'sha384-'.base64_encode($hash);

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Not sure if adding a var is worth it here. This code is not in the hotpath, so i'd maybe vote for code readability.

wdyt ?

OskarStark and Kocal reacted with thumbs up emoji
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@fabpot
Copy link
Member

@smnandre Is it still something you want to finish working on?

@smnandre
Copy link
MemberAuthor

I may find some time to.. but not before mid-week :|

@smnandre
Copy link
MemberAuthor

Closing in favor of#60378 that did find the time.

Thank you@pierreboissinot for the early help, sorry to not have found more time on this topic.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@KocalKocalKocal left review comments

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

[AssetMapper] Support SRI (integrity hashes)
5 participants
@smnandre@pierreboissinot@fabpot@Kocal@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp