IJPL-253651 [ssr] disable all script constraints for untrusted projects

(cherry picked from commit bfc7e228412484b7a7c2d97a6060eab483597676)

IJ-CR-221143

GitOrigin-RevId: 389c925c3d03d680a82daa719dd80256e2c8d4ee
This commit is contained in:
Bas Leijdekkers
2026-09-01 12:27:48 +00:00
committed by intellij-monorepo-bot
parent 77efa286a4
commit 9f6c162fc3
2 changed files with 7 additions and 2 deletions
@@ -274,7 +274,8 @@ error.bad.character.literal=Bad character literal
error.bad.literal=Bad literal
error.pattern.recursively.references.itself=Template recursively references itself
error.configuration.0.not.found=Template ''{0}'' not found
error.script.constraint.for.0.has.problem.1=Script constraint for {0} has problem {1}
error.script.constraint.for.0.has.problem.1=The script constraint for the variable {0} has a problem: {1}
error.scripts.untrusted=Scripts will not be executed because the project is not trusted
error.groovy.script.engine.not.available=Groovy script engine is not available
error.in.groovy.parser=Error in Groovy parser
@@ -1,6 +1,7 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.structuralsearch.impl.matcher.predicates;
import com.intellij.ide.trustedProjects.TrustedProjects;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.project.Project;
@@ -105,6 +106,9 @@ public final class ScriptSupport {
@NotNull String scriptText,
@NotNull MatchOptions matchOptions
) throws MalformedPatternException {
if (!TrustedProjects.isProjectTrusted(project)) {
throw new MalformedPatternException(SSRBundle.message("error.scripts.untrusted"));
}
final List<StructuralSearchScriptEngine> engines = StructuralSearchScriptEngine.EP_NAME.getExtensionList();
if (engines.isEmpty()) {
throw new MalformedPatternException(SSRBundle.message("error.groovy.script.engine.not.available"));