Skip to content

chore: Bloquer plus d'extension de fichiers et de domaines de tracking#598

Merged
yann120 merged 4 commits into
mainfrom
chore/block-pdf
Jul 1, 2026
Merged

chore: Bloquer plus d'extension de fichiers et de domaines de tracking#598
yann120 merged 4 commits into
mainfrom
chore/block-pdf

Conversation

@yann120

@yann120 yann120 commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Cette PR étend la blocklist utilisée par le navigateur d’audit pour éviter de charger des ressources inutiles à l’analyse.

Changements principaux :

  • partage des listes d’extensions entre Browser et Page
  • blocage des documents téléchargeables courants : PDF, Office, OpenDocument, texte, CSV/TSV, iWork
  • blocage de ressources statiques supplémentaires : polices, images, audio, vidéo, flux, calendriers
  • ajout de domaines de tracking courants rencontrés pendant le scraping
  • ajout d’un pattern Sentry générique pour couvrir sentry.io, sentry.incubateur.net et autres variantes similaires

@yann120 yann120 marked this pull request as ready for review June 22, 2026 07:32
@yann120 yann120 requested a review from Josyann June 22, 2026 07:32
@Josyann

Josyann commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Super ! Mais on avait discuté du fait de bloquer d'autres extensions aussi (listées dans page.rb) si possible/besoin. Tu as pris le temps de regarder ?

@Josyann

Josyann commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

J'y pense mais y'a sentry.incubateur.net aussi

@yann120 yann120 changed the title chore: block pdf files in order to increase browser performance chore: Bloquer plus d'extension de fichiers et de domaines de tracking Jun 24, 2026
@yann120 yann120 requested review from Josyann and removed request for Josyann June 24, 2026 14:30
@yann120 yann120 self-assigned this Jun 24, 2026
@yann120 yann120 added the chore Technical task label Jun 24, 2026
@yann120 yann120 linked an issue Jun 24, 2026 that may be closed by this pull request
Comment thread app/models/browser.rb
Comment on lines +10 to 32
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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

bonne idée! 👍🏻

Comment thread app/models/page.rb Outdated
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)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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 !

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

oui très bien, je suis pour la lisibilité 👍🏻

@Josyann

Josyann commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Voir pour les <embed></embed>
http://heberville.fr/

Co-authored-by: Josyann <Josyann@users.noreply.github.com>
@yann120

yann120 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

Voir pour les <embed></embed> http://heberville.fr/

@Josyann j'ai testé avec seulement embed pour voir si ca a un impact, et ça en a pas du tout sur le navigateur car ces INVISIBLE_ELEMENTS servent a retirer des élements dans la fonction dom qui nous retourne le HTML que l'on sauvegarde.

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.
Le scraping est aussi beaucoup rapide sur cette page avec cette PR : 1 seconde vs 30 a 60 secondes (peut etre le timeout)

@yann120

yann120 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator Author

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.
Exemple : http://heberville.fr/

0.583 seconds pour la version avec les extensions de fichiers bloqués (ici l'ajout du .pdf fait effet)
121.38 seconds sur main

@yann120 yann120 merged commit 8bbca89 into main Jul 1, 2026
10 checks passed
@yann120 yann120 deleted the chore/block-pdf branch July 1, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Technical task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] Bloquer plus d'extension de fichiers et de domaines de tracking

2 participants