Merge branch 'master' into dependabot/github_actions/ossf/scorecard-action-2.4.0

This commit is contained in:
Eugene Kliuchnikov 2024-11-12 16:55:37 +01:00 committed by GitHub
commit 0e37f9391d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 136 additions and 38 deletions

View File

@ -266,7 +266,7 @@ jobs:
if: ${{ matrix.build_system == 'bazel' }} if: ${{ matrix.build_system == 'bazel' }}
run: | run: |
cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }} cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }}
bazelisk build -c opt ...:all bazelisk build -c opt ...:all --java_runtime_version=remotejdk_21
- name: Fix symlinks for Bazel (Windows) - name: Fix symlinks for Bazel (Windows)
if: ${{ matrix.build_system == 'bazel' && runner.os == 'Windows' && matrix.bazel_project == 'java' }} if: ${{ matrix.build_system == 'bazel' && runner.os == 'Windows' && matrix.bazel_project == 'java' }}
@ -311,7 +311,7 @@ jobs:
run: | run: |
cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }} cd ${GITHUB_WORKSPACE}/${{ matrix.bazel_project }}
bazelisk query "tests(...)" --output=label > ${RUNNER_TEMP}/tests.lst bazelisk query "tests(...)" --output=label > ${RUNNER_TEMP}/tests.lst
[ -s ${RUNNER_TEMP}/tests.lst ] && bazelisk test -c opt ...:all [ -s ${RUNNER_TEMP}/tests.lst ] && bazelisk test -c opt ...:all --java_runtime_version=remotejdk_21
bazelisk clean bazelisk clean
- name: Build / Test with Maven - name: Build / Test with Maven
@ -324,7 +324,7 @@ jobs:
# cd integration # cd integration
# mvn -B verify # mvn -B verify
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
if: ${{ matrix.build_system == 'python' }} if: ${{ matrix.build_system == 'python' }}
with: with:
python-version: ${{ matrix.python_version }} python-version: ${{ matrix.python_version }}

View File

@ -28,7 +28,7 @@ jobs:
fuzz-seconds: 600 fuzz-seconds: 600
dry-run: false dry-run: false
- name: Upload Crash - name: Upload Crash
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: failure() if: failure()
with: with:
name: artifacts name: artifacts

View File

@ -53,7 +53,7 @@ jobs:
submodules: false submodules: false
fetch-depth: 1 fetch-depth: 1
- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-vcpkg id: cache-vcpkg
with: with:
path: vcpkg path: vcpkg
@ -102,7 +102,7 @@ jobs:
cmake --build out --config Release --target install cmake --build out --config Release --target install
cp LICENSE prefix/bin/LICENSE.brotli cp LICENSE prefix/bin/LICENSE.brotli
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: brotli-${{matrix.triplet}} name: brotli-${{matrix.triplet}}
path: | path: |

View File

@ -63,7 +63,7 @@ jobs:
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab. # format to the repository Actions tab.
- name: "Upload artifact" - name: "Upload artifact"
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with: with:
name: SARIF file name: SARIF file
path: results.sarif path: results.sarif

View File

@ -466,6 +466,53 @@ static BROTLI_INLINE brotli_reg_t ReadPreloadedSymbol(const HuffmanCode* table,
return result; return result;
} }
/* Reads up to limit symbols from br and copies them into ringbuffer,
starting from pos. Caller must ensure that there is enough space
for the write. Returns the amount of symbols actually copied. */
static BROTLI_INLINE int BrotliCopyPreloadedSymbolsToU8(const HuffmanCode* table,
BrotliBitReader* br,
brotli_reg_t* bits,
brotli_reg_t* value,
uint8_t* ringbuffer,
int pos,
const int limit) {
/* Calculate range where CheckInputAmount is always true.
Start with the number of bytes we can read. */
int64_t new_lim = br->guard_in - br->next_in;
/* Convert to bits, since sybmols use variable number of bits. */
new_lim *= 8;
/* At most 15 bits per symbol, so this is safe. */
new_lim /= 15;
const int kMaximalOverread = 4;
int pos_limit = limit;
int copies = 0;
if ((new_lim - kMaximalOverread) <= limit) {
// Safe cast, since new_lim is already < num_steps
pos_limit = (int)(new_lim - kMaximalOverread);
}
if (pos_limit < 0) {
pos_limit = 0;
}
copies = pos_limit;
pos_limit += pos;
/* Fast path, caller made sure it is safe to write,
we verified that is is safe to read. */
for (; pos < pos_limit; pos++) {
BROTLI_DCHECK(BrotliCheckInputAmount(br));
ringbuffer[pos] = (uint8_t)ReadPreloadedSymbol(table, br, bits, value);
BROTLI_LOG_ARRAY_INDEX(ringbuffer, pos);
}
/* Do the remainder, caller made sure it is safe to write,
we need to bverify that it is safe to read. */
while (BrotliCheckInputAmount(br) && copies < limit) {
ringbuffer[pos] = (uint8_t)ReadPreloadedSymbol(table, br, bits, value);
BROTLI_LOG_ARRAY_INDEX(ringbuffer, pos);
pos++;
copies++;
}
return copies;
}
static BROTLI_INLINE brotli_reg_t Log2Floor(brotli_reg_t x) { static BROTLI_INLINE brotli_reg_t Log2Floor(brotli_reg_t x) {
brotli_reg_t result = 0; brotli_reg_t result = 0;
while (x) { while (x) {
@ -1959,35 +2006,72 @@ CommandInner:
brotli_reg_t bits; brotli_reg_t bits;
brotli_reg_t value; brotli_reg_t value;
PreloadSymbol(safe, s->literal_htree, br, &bits, &value); PreloadSymbol(safe, s->literal_htree, br, &bits, &value);
do { if (!safe) {
if (!CheckInputAmount(safe, br)) { // This is a hottest part of the decode, so we copy the loop below
s->state = BROTLI_STATE_COMMAND_INNER; // and optimize it by calculating the number of steps where all checks
result = BROTLI_DECODER_NEEDS_MORE_INPUT; // evaluate to false (ringbuffer size/block size/input size).
goto saveStateAndReturn; // Since all checks are loop invariant, we just need to find
// minimal number of iterations for a simple loop, and run
// the full version for the remainder.
int num_steps = i - 1;
if (num_steps > 0 && ((brotli_reg_t)(num_steps) > s->block_length[0])) {
// Safe cast, since block_length < steps
num_steps = (int)s->block_length[0];
} }
if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) { if (s->ringbuffer_size >= pos &&
goto NextLiteralBlock; (s->ringbuffer_size - pos) <= num_steps) {
num_steps = s->ringbuffer_size - pos - 1;
} }
if (!safe) { if (num_steps < 0) {
s->ringbuffer[pos] = num_steps = 0;
(uint8_t)ReadPreloadedSymbol(s->literal_htree, br, &bits, &value); }
} else { num_steps = BrotliCopyPreloadedSymbolsToU8(s->literal_htree, br, &bits,
&value, s->ringbuffer, pos,
num_steps);
pos += num_steps;
s->block_length[0] -= (brotli_reg_t)num_steps;
i -= num_steps;
do {
if (!CheckInputAmount(safe, br)) {
s->state = BROTLI_STATE_COMMAND_INNER;
result = BROTLI_DECODER_NEEDS_MORE_INPUT;
goto saveStateAndReturn;
}
if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) {
goto NextLiteralBlock;
}
BrotliCopyPreloadedSymbolsToU8(s->literal_htree, br, &bits, &value,
s->ringbuffer, pos, 1);
--s->block_length[0];
BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos);
++pos;
if (BROTLI_PREDICT_FALSE(pos == s->ringbuffer_size)) {
s->state = BROTLI_STATE_COMMAND_INNER_WRITE;
--i;
goto saveStateAndReturn;
}
} while (--i != 0);
} else { /* safe */
do {
if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) {
goto NextLiteralBlock;
}
brotli_reg_t literal; brotli_reg_t literal;
if (!SafeReadSymbol(s->literal_htree, br, &literal)) { if (!SafeReadSymbol(s->literal_htree, br, &literal)) {
result = BROTLI_DECODER_NEEDS_MORE_INPUT; result = BROTLI_DECODER_NEEDS_MORE_INPUT;
goto saveStateAndReturn; goto saveStateAndReturn;
} }
s->ringbuffer[pos] = (uint8_t)literal; s->ringbuffer[pos] = (uint8_t)literal;
} --s->block_length[0];
--s->block_length[0]; BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos);
BROTLI_LOG_ARRAY_INDEX(s->ringbuffer, pos); ++pos;
++pos; if (BROTLI_PREDICT_FALSE(pos == s->ringbuffer_size)) {
if (BROTLI_PREDICT_FALSE(pos == s->ringbuffer_size)) { s->state = BROTLI_STATE_COMMAND_INNER_WRITE;
s->state = BROTLI_STATE_COMMAND_INNER_WRITE; --i;
--i; goto saveStateAndReturn;
goto saveStateAndReturn; }
} } while (--i != 0);
} while (--i != 0); }
} else { } else {
uint8_t p1 = s->ringbuffer[(pos - 1) & s->ringbuffer_mask]; uint8_t p1 = s->ringbuffer[(pos - 1) & s->ringbuffer_mask];
uint8_t p2 = s->ringbuffer[(pos - 2) & s->ringbuffer_mask]; uint8_t p2 = s->ringbuffer[(pos - 2) & s->ringbuffer_mask];

View File

@ -7,15 +7,29 @@ local_repository(
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
RULES_JAVA_VERSION = "8.3.2"
RULES_JAVA_SHA = "9b9614f8a7f7b7ed93cb7975d227ece30fe7daed2c0a76f03a5ee37f69e437de"
RULES_JVM_EXTERNAL_TAG = "4.0" RULES_JVM_EXTERNAL_TAG = "4.0"
RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169" RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169"
RULES_KOTLIN_VERSION = "1.9.0" RULES_KOTLIN_VERSION = "1.9.0"
RULES_KOTLIN_SHA = "5766f1e599acf551aa56f49dab9ab9108269b03c557496c54acaf41f98e2b8d6" RULES_KOTLIN_SHA = "5766f1e599acf551aa56f49dab9ab9108269b03c557496c54acaf41f98e2b8d6"
http_archive(
name = "rules_java",
sha256 = RULES_JAVA_SHA,
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/%s/rules_java-%s.tar.gz" % (RULES_JAVA_VERSION, RULES_JAVA_VERSION),
],
)
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
rules_java_dependencies()
rules_java_toolchains()
http_archive( http_archive(
name = "rules_jvm_external", name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA, sha256 = RULES_JVM_EXTERNAL_SHA,
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
) )
@ -23,15 +37,15 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
http_archive( http_archive(
name = "rules_kotlin", name = "rules_kotlin",
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v%s/rules_kotlin-v%s.tar.gz" % (RULES_KOTLIN_VERSION, RULES_KOTLIN_VERSION)],
sha256 = RULES_KOTLIN_SHA, sha256 = RULES_KOTLIN_SHA,
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/v%s/rules_kotlin-v%s.tar.gz" % (RULES_KOTLIN_VERSION, RULES_KOTLIN_VERSION)],
) )
load("@rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories") load("@rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
kotlin_repositories() # if you want the default. Otherwise see custom kotlinc distribution below
load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below kt_register_toolchains() # to use the default toolchain, otherwise see toolchains below
maven_install( maven_install(
artifacts = ["junit:junit:4.12"], artifacts = ["junit:junit:4.12"],
@ -43,37 +57,37 @@ maven_install(
http_archive( http_archive(
name = "platforms", name = "platforms",
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
urls = [ urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz", "https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
], ],
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
) )
http_file( http_file(
name = "openjdk_jni_h", name = "openjdk_jni_h",
downloaded_file_path = "jni.h", downloaded_file_path = "jni.h",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/share/javavm/export/jni.h"],
sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4", sha256 = "ed99792df48670072b78028faf704a8dcb6868fe140ccc7eced9b01dfa62fef4",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/share/javavm/export/jni.h"],
) )
http_file( http_file(
name = "openjdk_solaris_jni_md_h", name = "openjdk_solaris_jni_md_h",
downloaded_file_path = "jni_md.h", downloaded_file_path = "jni_md.h",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/solaris/javavm/export/jni_md.h"],
sha256 = "b6cf7b06e5bba38d2daa2ff0789f99d396b3cb3bcc37d0367c8360fdccdef294", sha256 = "b6cf7b06e5bba38d2daa2ff0789f99d396b3cb3bcc37d0367c8360fdccdef294",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/solaris/javavm/export/jni_md.h"],
) )
http_file( http_file(
name = "openjdk_macosx_jni_md_h", name = "openjdk_macosx_jni_md_h",
downloaded_file_path = "jni_md.h", downloaded_file_path = "jni_md.h",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/macosx/javavm/export/jni_md.h"],
sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4", sha256 = "8f718071022e7e7f2fc9a229984b7e83582db91ed83861b49ce1461436fe8dc4",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/macosx/javavm/export/jni_md.h"],
) )
http_file( http_file(
name = "openjdk_windows_jni_md_h", name = "openjdk_windows_jni_md_h",
downloaded_file_path = "jni_md.h", downloaded_file_path = "jni_md.h",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/windows/javavm/export/jni_md.h"],
sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b", sha256 = "5479fb385ea1e11619f5c0cdfd9ccb3ea3a3fea0f5bc6176fb3ce62be29d759b",
urls = ["https://raw.githubusercontent.com/openjdk/jdk/jdk8-b120/jdk/src/windows/javavm/export/jni_md.h"],
) )

View File

@ -1,6 +1,6 @@
"""Utilities for Java brotli tests.""" """Utilities for Java brotli tests."""
load("//third_party/bazel_rules/rules_java/java:java_test.bzl", "java_test") load("@rules_java//java:java_test.bzl", "java_test")
_TEST_JVM_FLAGS = [ _TEST_JVM_FLAGS = [
"-DBROTLI_ENABLE_ASSERTS=true", "-DBROTLI_ENABLE_ASSERTS=true",