chore: Bloquer plus d'extension de fichiers et de domaines de tracking#598
Conversation
|
Super ! Mais on avait discuté du fait de bloquer d'autres extensions aussi (listées dans |
|
J'y pense mais y'a |
| DOCUMENT_EXTENSIONS = [ | ||
| # PDF and archives | ||
| %w[.pdf .zip], | ||
| # OpenDocument and Microsoft Office | ||
| %w[.odt .ods .odp .odg .doc .docx .xls .xlsx .ppt .pptx], | ||
| # Text, data, and Apple iWork | ||
| %w[.rtf .txt .csv .tsv .pages .numbers], | ||
| ].flatten.freeze | ||
|
|
||
| FILE_EXTENSIONS = [ | ||
| # Fonts | ||
| %w[.woff .woff2 .ttf .otf .eot], | ||
| # Feeds, structured data, calendars, icons, and cursors | ||
| %w[.xml .rss .atom .ics .ical .ico .cur], | ||
| # Images | ||
| %w[.jpg .jpeg .png .gif .bmp .svg .webp .avif .tif .tiff .apng .heic .heif], | ||
| # Audio and video | ||
| %w[.mp3 .mp4 .avi .mov .mkv .webm .ogg .wav .aac .flac .m4a .opus], | ||
| %w[.ogv .m4v .mpg .mpeg], | ||
| ].flatten.freeze | ||
|
|
||
| BLOCKED_FILE_EXTENSIONS = (FILE_EXTENSIONS + DOCUMENT_EXTENSIONS).freeze | ||
|
|
There was a problem hiding this comment.
| DOCUMENT_EXTENSIONS = [ | |
| # PDF and archives | |
| %w[.pdf .zip], | |
| # OpenDocument and Microsoft Office | |
| %w[.odt .ods .odp .odg .doc .docx .xls .xlsx .ppt .pptx], | |
| # Text, data, and Apple iWork | |
| %w[.rtf .txt .csv .tsv .pages .numbers], | |
| ].flatten.freeze | |
| FILE_EXTENSIONS = [ | |
| # Fonts | |
| %w[.woff .woff2 .ttf .otf .eot], | |
| # Feeds, structured data, calendars, icons, and cursors | |
| %w[.xml .rss .atom .ics .ical .ico .cur], | |
| # Images | |
| %w[.jpg .jpeg .png .gif .bmp .svg .webp .avif .tif .tiff .apng .heic .heif], | |
| # Audio and video | |
| %w[.mp3 .mp4 .avi .mov .mkv .webm .ogg .wav .aac .flac .m4a .opus], | |
| %w[.ogv .m4v .mpg .mpeg], | |
| ].flatten.freeze | |
| BLOCKED_FILE_EXTENSIONS = (FILE_EXTENSIONS + DOCUMENT_EXTENSIONS).freeze | |
| DOCUMENT_EXTENSIONS = [ | |
| # PDF and archives | |
| '.pdf', '.zip', | |
| # OpenDocument and Microsoft Office | |
| '.odt', '.ods', '.odp', '.odg', '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', | |
| # Text, data, and Apple iWork | |
| '.rtf', '.txt', '.csv', '.tsv', '.pages', '.numbers', | |
| ].freeze | |
| FILE_EXTENSIONS = [ | |
| # Fonts | |
| '.woff', '.woff2', '.ttf', '.otf', '.eot', | |
| # Feeds, structured data, calendars, icons, and cursors | |
| '.xml', '.rss', '.atom', '.ics', '.ical', '.ico', '.cur', | |
| # Images | |
| '.jpg', '.jpeg', '.png', '.gif', '.bmp', '.svg', '.webp', '.avif', '.tif', '.tiff', '.apng', '.heic', '.heif', | |
| # Audio and video | |
| '.mp3', '.mp4', '.avi', '.mov', '.mkv', '.webm', '.ogg', '.wav', '.aac', '.flac', '.m4a', '.opus', | |
| '.ogv', '.m4v', '.mpg', '.mpeg', | |
| ].freeze | |
| BLOCKED_FILE_EXTENSIONS = (FILE_EXTENSIONS + DOCUMENT_EXTENSIONS).freeze |
| next if uri.path && File.extname(uri.path).match?(FILES_EXTENSIONS) | ||
| next if skip_files && uri.path && File.extname(uri.path).match?(DOCUMENT_EXTENSIONS) | ||
| next if uri.path && Browser::FILE_EXTENSIONS.include?(File.extname(uri.path).downcase) | ||
| next if skip_files && uri.path && Browser::DOCUMENT_EXTENSIONS.include?(File.extname(uri.path).downcase) |
There was a problem hiding this comment.
| next if skip_files && uri.path && Browser::DOCUMENT_EXTENSIONS.include?(File.extname(uri.path).downcase) | |
| next if skipped_file_link?(uri, skip_files:) | |
| [...] | |
| private | |
| def skipped_file_link?(uri, skip_files:) | |
| return false unless uri.path | |
| path_extension = File.extname(uri.path).downcase | |
| Browser::FILE_EXTENSIONS.include?(path_extension) || | |
| skip_files && Browser::DOCUMENT_EXTENSIONS.include?(path_extension) | |
| end |
Ça rajoute des lignes mais je trouve ça plus lisible. Comme tu veux !
There was a problem hiding this comment.
oui très bien, je suis pour la lisibilité 👍🏻
|
Voir pour les |
Co-authored-by: Josyann <Josyann@users.noreply.github.com>
@Josyann j'ai testé avec seulement Je n'ai pas trouvé de moyen "simple" de supprimer une partie du html, comme les attributs embed avant le chargement de la page... mais la bonne nouvelle c'est que bloquer les extensions PDF (cette fois c'est fait coté Ferrum) ne charge pas ces fichiers qui sont dans le embed comme sur http://heberville.fr/ et donc on affiche pas les iFrame injectés par Chrome pour afficher son extension de lecteur de PDF. |
|
Comparaison sur 250 audits : pas de différence... 9,8 minutes pour cette branche et sur main Mais de grosse differences quand on lance un seul site. 0.583 seconds pour la version avec les extensions de fichiers bloqués (ici l'ajout du .pdf fait effet) |
Cette PR étend la blocklist utilisée par le navigateur d’audit pour éviter de charger des ressources inutiles à l’analyse.
Changements principaux :
BrowseretPagesentry.io,sentry.incubateur.netet autres variantes similaires