Skip to content

Commit

Permalink
Merge pull request #114 from CybercentreCanada/brower_config
Browse files Browse the repository at this point in the history
Open configuration of browser to administrators
  • Loading branch information
cccs-rs authored Mar 25, 2024
2 parents e5a1934 + 8ba8245 commit 4364d1d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions document_preview/document_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ class DocumentPreview(ServiceBase):
def __init__(self, config=None):
super(DocumentPreview, self).__init__(config)

# Set browser to run headless without scrollbars
browser_options = ChromeOptions()
browser_options.add_argument("--headless")
browser_options.add_argument("--no-sandbox")
browser_options.add_argument("--hide-scrollbars")

# Set brower options depending on service configuration
browser_cfg = config.get('browser_options', {})
[browser_options.add_argument(arg) for arg in browser_cfg.get('arguments', [])]
[browser_options.set_capability(cap_n, cap_v) for cap_n, cap_v in browser_cfg.get('capabilities', {}).items()]

# Run browser in offline mode only
self.browser = Chrome(options=browser_options, service=ChromeService(executable_path="/usr/bin/chromedriver"))
Expand Down
8 changes: 8 additions & 0 deletions service_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ config:
banned: [] # Banned terms
macros: [] # Terms that indicate macros
ransomware: [] # Terms that indicate ransomware
browser_options:
capabilities:
pageLoadStrategy: normal
# Set browser to run headless without scrollbars
arguments:
- "--headless"
- "--no-sandbox"
- "--hide-scrollbars"
heuristics:
- heur_id: 1
name: OCR Detection found
Expand Down

0 comments on commit 4364d1d

Please sign in to comment.