Skip to content

Commit

Permalink
Automatic merge of master into galahad
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Dec 3, 2024
2 parents 09096a5 + 0046d69 commit 05925e2
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 144 deletions.
4 changes: 2 additions & 2 deletions compiler/ci/ci_common/benchmark-suites.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
run+: [
self.benchmark_cmd + ["scala-dacapo:*", "--"] + self.extra_vm_args
],
timelimit: "01:00:00",
timelimit: "01:30:00",
forks_batches:: 2,
bench_forks_per_batch:: 3,
forks_timelimit:: "02:30:00",
Expand Down Expand Up @@ -105,7 +105,7 @@
run+: [
self.benchmark_cmd + ["renaissance:*"] + suite_version_args + ["--"] + self.extra_vm_args
],
timelimit: "2:00:00",
timelimit: "2:30:00",
forks_batches:: 4,
bench_forks_per_batch:: 2,
forks_timelimit:: "4:00:00",
Expand Down
20 changes: 7 additions & 13 deletions compiler/ci/ci_includes/baseline-benchmarks.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
local bench = (import '../ci_common/benchmark-suites.libsonnet'),
local hw = bc.bench_hw,

local hotspot_amd64_builds = [
c.weekly + hw.e3 + jdk + cc.c2 + suite
local hotspot_builds = std.flattenArrays([
[
c.weekly + hw.e3 + jdk + cc.c2 + suite,
c.weekly + hw.a12c + jdk + cc.c2 + suite
]
for jdk in cc.jdks_of_interest
for suite in bench.groups.all_suites
],

local hotspot_aarch64_builds = [
c.weekly + hw.a12c + jdk + cc.c2 + suite
for jdk in cc.jdks_of_interest
for suite in bench.groups.main_suites
] + [
c.monthly + hw.a12c + jdk + cc.c2 + bench.specjbb2015,
for jdk in cc.product_jdks
],
]),

local hotspot_profiling_builds = std.flattenArrays([
[
Expand Down Expand Up @@ -73,7 +67,7 @@
]
for jdk in cc.product_jdks
]),
local all_builds = hotspot_amd64_builds + hotspot_aarch64_builds + hotspot_profiling_builds +
local all_builds = hotspot_builds + hotspot_profiling_builds +
weekly_forks_amd64_builds + weekly_forks_aarch64_builds + economy_builds + no_tiered_builds + gc_variants_builds,
local filtered_builds = [b for b in all_builds if b.is_jdk_supported(b.jdk_version) && b.is_arch_supported(b.arch)],

Expand Down
18 changes: 16 additions & 2 deletions docs/security/SBOM.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,20 @@ It outputs the SBOM in the following format:

## Vulnerability Scanning

To scan for any vulnerable libraries, submit the SBOM to a vulnerability scanner.
For example, the popular [Anchore software supply chain management platform](https://anchore.com/) makes the `grype` scanner freely available.
To scan for vulnerable libraries, use either the [GraalVM GitHub Action](https://github.com/marketplace/actions/github-action-for-graalvm) for automated scanning, or submit the SBOM to a vulnerability scanner directly.

### GitHub Integration

When using the [GraalVM GitHub Action](https://github.com/marketplace/actions/github-action-for-graalvm), the SBOM can be automatically generated and submitted to GitHub's dependency submission API for continuous scanning.
This enables:
- Vulnerability tracking with GitHub's Dependabot.
- Dependency tracking with GitHub's Dependency Graph.

If you use GitHub, this integration offers you the simplest setup and powerful security tooling.

### Command-Line Scanning

The popular [Anchore software supply chain management platform](https://anchore.com/) makes the `grype` scanner available for free.
You can check whether the libraries given in your SBOMs have known vulnerabilities documented in Anchore's database.
For this purpose, the output of the tool can be fed directly to the `grype` scanner to check for vulnerable libraries, using the command `$JAVA_HOME/bin/native-image-inspect --sbom <path_to_binary> | grype` which produces the following output:
```shell
Expand All @@ -91,6 +103,8 @@ This dependency information is derived from Native Image's static analysis call
Analyzing the dependency graph can help you understand why specific components are included in your application.
For example, discovering an unexpected component in the SBOM allows for tracing its inclusion through the dependency graph to identify which parts of the application are using it.

With the GraalVM GitHub Action, you get access to GitHub's Dependency Graph feature.

## Enhanced SBOMs with Maven Plugin for Native Image

To generate more accurate SBOMs with richer component metadata, consider using the [Maven plugin for GraalVM Native Image](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html).
Expand Down
4 changes: 4 additions & 0 deletions regex/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This changelog summarizes major changes between TRegex versions relevant to language implementors integrating TRegex into their language. This document will focus on API changes relevant to integrators of TRegex.

## Version 24.2.0

* Implemented the [Regular Expression Pattern Modifiers](https://github.com/tc39/proposal-regexp-modifiers) proposal for ECMAScript regular expressions.

## Version 24.0.0

* Added support for atomic groups and possessive quantifiers in Python regular expressions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -50,6 +50,7 @@
import com.oracle.truffle.regex.tregex.util.json.Json;
import com.oracle.truffle.regex.tregex.util.json.JsonConvertible;
import com.oracle.truffle.regex.tregex.util.json.JsonValue;
import com.oracle.truffle.regex.util.TBitSet;
import com.oracle.truffle.regex.util.TruffleReadOnlyKeysArray;

@ExportLibrary(InteropLibrary.class)
Expand All @@ -76,6 +77,9 @@ public final class RegexFlags extends AbstractConstantKeysObject implements Json
PROP_HAS_INDICES,
PROP_UNICODE_SETS);

private static final TBitSet ALL_FLAG_CHARS = TBitSet.valueOf('d', 'g', 'i', 'm', 's', 'u', 'v', 'y');
private static final TBitSet LOCAL_FLAG_CHARS = TBitSet.valueOf('i', 'm', 's');

private static final int NONE = 0;
private static final int IGNORE_CASE = 1;
private static final int MULTILINE = 1 << 1;
Expand All @@ -86,6 +90,10 @@ public final class RegexFlags extends AbstractConstantKeysObject implements Json
private static final int HAS_INDICES = 1 << 6;
private static final int UNICODE_SETS = 1 << 7;

private static final int[] FLAG_LOOKUP = {
HAS_INDICES, 0, 0, GLOBAL, 0, IGNORE_CASE, 0, 0, 0, MULTILINE, 0, 0, 0, 0, 0, DOT_ALL, 0, UNICODE, UNICODE_SETS, 0, 0, STICKY
};

public static final RegexFlags DEFAULT = new RegexFlags("", NONE);

private final String source;
Expand All @@ -96,6 +104,17 @@ private RegexFlags(String source, int value) {
this.value = value;
}

private RegexFlags(int value) {
this.source = generateSource(value);
this.value = value;
}

private static int maskForFlag(char flagChar) {
assert ALL_FLAG_CHARS.get(flagChar);
// flagChar must be one of [d-y].
return FLAG_LOOKUP[flagChar - 'd'];
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -109,51 +128,21 @@ public static RegexFlags parseFlags(RegexSource source) throws RegexSyntaxExcept
int flags = NONE;
for (int i = 0; i < flagsStr.length(); i++) {
char ch = flagsStr.charAt(i);
switch (ch) {
case 'i':
flags = addFlag(source, flags, i, IGNORE_CASE);
break;
case 'm':
flags = addFlag(source, flags, i, MULTILINE);
break;
case 'g':
flags = addFlag(source, flags, i, GLOBAL);
break;
case 'y':
flags = addFlag(source, flags, i, STICKY);
break;
case 'u':
if ((flags & UNICODE_SETS) != 0) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.BOTH_FLAGS_SET_U_V, i);
}
flags = addFlag(source, flags, i, UNICODE);
break;
case 's':
flags = addFlag(source, flags, i, DOT_ALL);
break;
case 'd':
flags = addFlag(source, flags, i, HAS_INDICES);
break;
case 'v':
if ((flags & UNICODE) != 0) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.BOTH_FLAGS_SET_U_V, i);
}
flags = addFlag(source, flags, i, UNICODE_SETS);
break;
default:
throw RegexSyntaxException.createFlags(source, JsErrorMessages.UNSUPPORTED_FLAG, i);
if (!isValidFlagChar(ch)) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.UNSUPPORTED_FLAG, i);
}
int flag = maskForFlag(ch);
if ((flags & flag) != 0) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.REPEATED_FLAG, i);
}
flags |= flag;
if ((flags & (UNICODE | UNICODE_SETS)) == (UNICODE | UNICODE_SETS)) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.BOTH_FLAGS_SET_U_V, i);
}
}
return new RegexFlags(flagsStr, flags);
}

private static int addFlag(RegexSource source, int flags, int i, int flag) {
if ((flags & flag) != 0) {
throw RegexSyntaxException.createFlags(source, JsErrorMessages.REPEATED_FLAG, i);
}
return flags | flag;
}

public String getSource() {
return source;
}
Expand Down Expand Up @@ -202,6 +191,34 @@ private boolean isSet(int flag) {
return (value & flag) != NONE;
}

public static boolean isValidFlagChar(char candidateChar) {
return ALL_FLAG_CHARS.get(candidateChar);
}

public static boolean isValidLocalFlagChar(char candidateChar) {
return LOCAL_FLAG_CHARS.get(candidateChar);
}

public RegexFlags addNewFlagModifier(RegexSource regexSource, char flagChar) {
int flag = maskForFlag(flagChar);
if (isSet(flag)) {
throw RegexSyntaxException.createFlags(regexSource, JsErrorMessages.REPEATED_FLAG_IN_MODIFIER);
}
return new RegexFlags(this.value | flag);
}

public RegexFlags addFlags(RegexFlags otherFlags) {
return new RegexFlags(this.value | otherFlags.value);
}

public RegexFlags delFlags(RegexFlags otherFlags) {
return new RegexFlags(this.value & ~otherFlags.value);
}

public boolean overlaps(RegexFlags otherFlags) {
return (this.value & otherFlags.value) != 0;
}

@Override
public String toString() {
return source;
Expand Down Expand Up @@ -287,6 +304,35 @@ public Object toDisplayString(@SuppressWarnings("unused") boolean allowSideEffec
return "TRegexJSFlags{flags=" + toString() + '}';
}

private static String generateSource(int value) {
StringBuilder sb = new StringBuilder(8);
if ((value & IGNORE_CASE) != 0) {
sb.append("i");
}
if ((value & MULTILINE) != 0) {
sb.append("m");
}
if ((value & STICKY) != 0) {
sb.append("y");
}
if ((value & GLOBAL) != 0) {
sb.append("g");
}
if ((value & UNICODE) != 0) {
sb.append("u");
}
if ((value & DOT_ALL) != 0) {
sb.append("s");
}
if ((value & HAS_INDICES) != 0) {
sb.append("d");
}
if ((value & UNICODE_SETS) != 0) {
sb.append("v");
}
return sb.toString();
}

public static final class Builder {

private int value;
Expand Down Expand Up @@ -342,7 +388,7 @@ public Builder unicodeSets(boolean enabled) {

@TruffleBoundary
public RegexFlags build() {
return new RegexFlags(generateSource(), this.value);
return new RegexFlags(generateSource(this.value), this.value);
}

private void updateFlag(boolean enabled, int bitMask) {
Expand All @@ -352,38 +398,5 @@ private void updateFlag(boolean enabled, int bitMask) {
this.value &= ~bitMask;
}
}

private boolean isSet(int flag) {
return (value & flag) != NONE;
}

private String generateSource() {
StringBuilder sb = new StringBuilder(7);
if (isSet(IGNORE_CASE)) {
sb.append("i");
}
if (isSet(MULTILINE)) {
sb.append("m");
}
if (isSet(STICKY)) {
sb.append("y");
}
if (isSet(GLOBAL)) {
sb.append("g");
}
if (isSet(UNICODE)) {
sb.append("u");
}
if (isSet(DOT_ALL)) {
sb.append("s");
}
if (isSet(HAS_INDICES)) {
sb.append("d");
}
if (isSet(UNICODE_SETS)) {
sb.append("v");
}
return sb.toString();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -50,30 +50,36 @@ public class JsErrorMessages {
public static final String CHAR_CLASS_RANGE_OUT_OF_ORDER = "Range out of order in character class";
public static final String COMPLEMENT_OF_STRING_SET = "Negated character class may contain strings";
public static final String EMPTY_GROUP_NAME = "Empty named capture group name";
public static final String EMPTY_MODIFIER = "No flags in modifier";
public static final String ENDS_WITH_UNFINISHED_ESCAPE_SEQUENCE = "Ends with an unfinished escape sequence";
public static final String ENDS_WITH_UNFINISHED_UNICODE_PROPERTY = "Ends with an unfinished Unicode property escape";
public static final String INCOMPLETE_QUANTIFIER = "Incomplete quantifier";
public static final String INCOMPLETE_MODIFIER = "Incomplete modifier";
public static final String INVALID_CHARACTER_CLASS = "Invalid character class";
public static final String INVALID_CHARACTER_IN_CHARACTER_CLASS = "Invalid character in character class";
public static final String INVALID_CONTROL_CHAR_ESCAPE = "Invalid control char escape";
public static final String INVALID_ESCAPE = "Invalid escape";
public static final String INVALID_GROUP = "Invalid group";
public static final String INVALID_GROUP_NAME_PART = "Invalid character in group name";
public static final String INVALID_GROUP_NAME_START = "Invalid character at start of group name";
public static final String INVALID_MODIFIER = "Invalid modifier";
public static final String INVALID_UNICODE_ESCAPE = "Invalid Unicode escape";
public static final String INVALID_UNICODE_PROPERTY = "Invalid Unicode property escape";
public static final String MISSING_GROUP_FOR_BACKREFERENCE = "Missing capture group for backreference";
public static final String MISSING_GROUP_NAME = "Missing group name in named capture group reference";
public static final String MODIFIER_BOTH_ADDING_AND_REMOVING_FLAG = "Modifier is both adding and removing the same flag";
public static final String MULTIPLE_GROUPS_SAME_NAME = "Multiple named capture groups with the same name";
public static final String QUANTIFIER_ON_LOOKAHEAD_ASSERTION = "Quantifier on lookahead assertion";
public static final String QUANTIFIER_ON_LOOKBEHIND_ASSERTION = "Quantifier on lookbehind assertion";
public static final String QUANTIFIER_ON_QUANTIFIER = "Quantifier on quantifier";
public static final String QUANTIFIER_OUT_OF_ORDER = "Numbers out of order in {} quantifier";
public static final String QUANTIFIER_WITHOUT_TARGET = "Quantifier without target";
public static final String REPEATED_FLAG_IN_MODIFIER = "Repeated regex flag in modifier";
public static final String UNMATCHED_LEFT_BRACKET = "Unterminated character class";
public static final String UNMATCHED_RIGHT_BRACKET = "Unmatched ']'";
public static final String UNMATCHED_RIGHT_PARENTHESIS = "Unmatched ')'";
public static final String UNMATCHED_RIGHT_BRACE = "Unmatched '}'";
public static final String UNSUPPORTED_FLAG_IN_MODIFIER = "Invalid regular expression flag in modifier";
public static final String UNTERMINATED_GROUP = "Unterminated group";
public static final String UNTERMINATED_GROUP_NAME = "Unterminated group name";
public static final String UNTERMINATED_STRING_SET = "Unterminated string set";
Expand Down Expand Up @@ -103,6 +109,10 @@ public static String invalidRegularExpression(RegexSource source, String message
return String.format("Invalid regular expression: %s: %s", source, message);
}

public static String flagNotAllowedInModifier(char flagChar) {
return String.format("Flag '%s' not allowed in modifier", flagChar);
}

/* flag related errors */

public static final String REPEATED_FLAG = "Repeated regex flag";
Expand Down
Loading

0 comments on commit 05925e2

Please sign in to comment.