diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0fbb0d8a..de3a4017 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,6 +2,9 @@ name: Lint on: pull_request: +permissions: + contents: read + jobs: file-ref-check: name: file-ref-check diff --git a/.github/workflows/style.yml b/.github/workflows/style.yml index d89b19d2..e4f86a68 100644 --- a/.github/workflows/style.yml +++ b/.github/workflows/style.yml @@ -2,6 +2,9 @@ name: Vale on: pull_request: +permissions: + contents: read + jobs: vale: name: runner / vale diff --git a/common/src/components/flanksource/Navigation.jsx b/common/src/components/flanksource/Navigation.jsx index f1c58f47..4edce1ea 100644 --- a/common/src/components/flanksource/Navigation.jsx +++ b/common/src/components/flanksource/Navigation.jsx @@ -3,6 +3,15 @@ import React, { useState, useRef } from 'react'; import { FaChevronDown, FaChevronUp, FaBars, FaTimes, FaBullseye, FaSearch, FaDatabase, FaExclamationTriangle, FaRocket, FaTools, FaLifeRing, FaSync, FaLightbulb, FaEye, FaRobot } from 'react-icons/fa'; import { SiPostgresql } from 'react-icons/si'; +const isGitHubUrl = (href) => { + try { + const url = new URL(href); + return url.protocol === 'https:' && url.hostname === 'github.com'; + } catch { + return false; + } +}; + const Navigation = ({ logo = , loginButton = { href: "https://app.flanksource.com/", text: "Login" }, @@ -241,8 +250,8 @@ const Navigation = ({ key={index} href={product.href} className="flex items-start p-1 rounded-lg hover:bg-gray-50 transition-colors" - target={product.href.includes('github.com') ? '_blank' : '_self'} - rel={product.href.includes('github.com') ? 'noopener noreferrer' : ''} + target={isGitHubUrl(product.href) ? '_blank' : '_self'} + rel={isGitHubUrl(product.href) ? 'noopener noreferrer' : ''} >
{product.icon}
@@ -451,8 +460,8 @@ const Navigation = ({ key={index} href={product.href} className="flex items-start p-3 rounded-lg hover:bg-gray-50 transition-colors" - target={product.href.includes('github.com') ? '_blank' : '_self'} - rel={product.href.includes('github.com') ? 'noopener noreferrer' : ''} + target={isGitHubUrl(product.href) ? '_blank' : '_self'} + rel={isGitHubUrl(product.href) ? 'noopener noreferrer' : ''} >
{product.icon}
diff --git a/common/src/theme/prism-jq.js b/common/src/theme/prism-jq.js index 3cc030e7..e1753f70 100644 --- a/common/src/theme/prism-jq.js +++ b/common/src/theme/prism-jq.js @@ -1,7 +1,8 @@ (function (Prism) { var interpolation = /\\\((?:[^()]|\([^()]*\))*\)/.source; - var string = RegExp(/(^|[^\\])"(?:[^"\r\n\\]|\\[^\r\n(]|__)*"/.source.replace(/__/g, function () { return interpolation; })); + // Keep the string matcher linear-time; interpolation highlighting is handled below. + var string = /(^|[^\\])"(?:[^"\r\n\\]|\\[^\r\n])*"/; var stringInterpolation = { 'interpolation': { pattern: RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + interpolation),