Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/astro-prism/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export function addAstro(Prism: typeof import('prismjs')) {
.replace(/<SPREAD>/g, function () {
return spread;
});
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
// Built from static Prism token sources, not user input.
return RegExp(source, flags);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/core/app/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ export function deserializeRouteData(rawRouteData: SerializedRouteData): RouteDa
return {
route: rawRouteData.route,
type: rawRouteData.type,
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
// This pattern is serialized from Astro's own route manifest.
pattern: new RegExp(rawRouteData.pattern),
params: rawRouteData.params,
component: rawRouteData.component,
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/core/routing/pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export function getPattern(
if (addTrailingSlash === 'never' && base !== '/') {
initial = '';
}
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
// The pattern is assembled from escaped route segments generated by Astro.
return new RegExp(`^${pathname || initial}${trailing}`);
}

Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/prefetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ function onPageLoad(cb: () => void) {
function appendSpeculationRules(url: string, eagerness: PrefetchOptions['eagerness']) {
const script = document.createElement('script');
script.type = 'speculationrules';
// nosemgrep: javascript.lang.security.audit.unknown-value-with-script-tag.unknown-value-with-script-tag
// This writes JSON via textContent, not executable JavaScript source.
script.textContent = JSON.stringify({
prerender: [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/astro/src/vite-plugin-config-alias/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const getViteResolveAlias = (settings: AstroSettings) => {
// id is already the wildcard part (e.g., 'extra.css' for '@styles/*')
// resolvedValues still have the * in them, so replace * with id
for (const resolvedValue of resolvedValues) {
// nosemgrep: javascript.lang.security.audit.incomplete-sanitization.incomplete-sanitization
// `id` is the wildcard capture from the alias match and only substitutes the tsconfig `*`.
const resolved = resolvedValue.replace('*', id);
const stats = fs.statSync(resolved, { throwIfNoEntry: false });
if (stats && stats.isFile()) {
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/netlify/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export function remotePatternToRegex(
regexStr += '([?][^#]*)?';
}
try {
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
// This only validates the generated pattern before handing it to Netlify.
new RegExp(regexStr);
} catch {
logger.warn(
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/partytown/src/sirv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ export default function (dir, opts = {}) {
if (opts.dotfiles) ignores.push(/\/\.\w/);
else ignores.push(/\/\.well-known/);
[].concat(opts.ignores || []).forEach((x) => {
// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp
// This mirrors sirv's developer-supplied ignore patterns.
ignores.push(new RegExp(x, 'i'));
});
}
Expand Down
2 changes: 2 additions & 0 deletions packages/integrations/preact/src/static-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Props = {
const StaticHtml = ({ value, name, hydrate = true }: Props) => {
if (!value) return null;
const tagName = hydrate ? 'astro-slot' : 'astro-static-slot';
// nosemgrep: typescript.react.security.audit.react-dangerouslysetinnerhtml.react-dangerouslysetinnerhtml
// Astro passes framework-rendered HTML through this adapter boundary intentionally.
return h(tagName, { name, dangerouslySetInnerHTML: { __html: value } });
};

Expand Down
Loading