Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove binary artifacts due to security policy violation #1538

Merged
merged 11 commits into from
Feb 5, 2024
Merged
10 changes: 7 additions & 3 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
load("@rules_python//python:defs.bzl", "py_binary")
load("@rules_java//java:defs.bzl", "java_binary", "java_import", "java_library")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load(
"//scala:scala.bzl",
"scala_binary",
Expand Down Expand Up @@ -616,9 +616,13 @@ scala_library(
)

# make sure making a fat jar strips signatures
java_import(
java_library(
name = "fakejar",
jars = ["fake_sig.jar"],
resources = [
"//test/src/main/resources/META-INF:FAKE.DSA",
"//test/src/main/resources/META-INF:FAKE.RSA",
],
visibility = ["//visibility:public"],
)

scala_binary(
Expand Down
14 changes: 7 additions & 7 deletions test/example_jars/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
load("@rules_java//java:defs.bzl", "java_import")
load("@rules_java//java:defs.bzl", "java_library")

java_import(
java_library(
name = "example_jar1",
jars = [
"example_jar1.jar",
resources = [
"//test/src/main/resources/META-INF/services:org.apache.beam.sdk.io.FileSystemRegistrar",
],
visibility = ["//visibility:public"],
)

java_import(
java_library(
name = "example_jar2",
jars = [
"example_jar2.jar",
resources = [
"//test/src/main/resources/META-INF/services:org.apache.beam.sdk.io.FileSystemRegistrar",
],
visibility = ["//visibility:public"],
)
Binary file removed test/example_jars/example_jar1.jar
Binary file not shown.
Binary file removed test/example_jars/example_jar2.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion test/example_jars/expected_service_manifest.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar
org.apache.beam.sdk.io.LocalFileSystemRegistrar
org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
Binary file removed test/fake_sig.jar
Binary file not shown.
4 changes: 4 additions & 0 deletions test/src/main/resources/META-INF/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports_files([
"FAKE.DSA",
"FAKE.RSA",
])
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions test/src/main/resources/META-INF/services/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports_files([
"org.apache.beam.sdk.io.FileSystemRegistrar",
])
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.beam.sdk.extensions.gcp.storage.GcsFileSystemRegistrar
4 changes: 3 additions & 1 deletion test/src/main/resources/scalarules/test/BUILD
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
exports_files([
"byes",
"hellos",
"hellos-and-byes.jar",
"more-byes",
"more-hellos",
"Foo.thrift",
"Bar.thrift",
"Baz.thrift",
])

genrule(
Expand Down
5 changes: 5 additions & 0 deletions test/src/main/resources/scalarules/test/Bar.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Bar {
1: optional string Bar
}
5 changes: 5 additions & 0 deletions test/src/main/resources/scalarules/test/Baz.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Baz {
1: optional string Baz
}
5 changes: 5 additions & 0 deletions test/src/main/resources/scalarules/test/Foo.thrift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Foo {
1: optional string foo
}
Binary file not shown.
14 changes: 13 additions & 1 deletion test/src/main/scala/scalarules/test/resource_jars/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
load("@rules_java//java:defs.bzl", "java_library")
load("//scala:scala.bzl", "scala_test")

java_library(
name = "jarWithResources",
resources = [
"//test/src/main/resources/scalarules/test:byes",
"//test/src/main/resources/scalarules/test:hellos",
"//test/src/main/resources/scalarules/test:more-byes",
"//test/src/main/resources/scalarules/test:more-hellos",
],
visibility = ["//visibility:public"],
)

scala_test(
name = "resource_jars",
srcs = ["TestResourceJars.scala"],
resource_jars = ["//test/src/main/resources/scalarules/test:hellos-and-byes.jar"],
resource_jars = [":jarWithResources"],
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TestResourceJars extends AnyFlatSpec {
)
expectedSubstrings.foreach {
case (resource_name, substring) => {
val stream = getClass.getResourceAsStream("/" + resource_name)
val stream = getClass.getResourceAsStream("/scalarules/test/" + resource_name)
assert(stream != null, s"failed to find resource $resource_name")
val content = Source.fromInputStream(stream).getLines().mkString("\n")
assert(content.contains(substring), s"resource $resource_name did not contain substring $substring")
Expand Down
22 changes: 3 additions & 19 deletions test/src/main/scala/scalarules/test/scala_import/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ scala_import(
],
)

# Jars as files
scala_import(
name = "relate",
jars = [
"relate_2.11-2.1.1.jar",
],
)

scala_specs2_junit_test(
name = "scala_import_exposes_jars",
size = "small",
Expand All @@ -36,14 +28,6 @@ scala_specs2_junit_test(
deps = [":guava_and_commons_lang"],
)

scala_specs2_junit_test(
name = "scala_import_exposes_file_jars",
size = "small",
srcs = ["ScalaImportExposesFileJarsTest.scala"],
suffixes = ["Test"],
deps = [":relate"],
)

mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
scala_library(
name = "source_jar_not_oncp",
testonly = True,
Expand Down Expand Up @@ -123,15 +107,15 @@ scala_specs2_junit_test(
# https://github.com/bazelbuild/rules_scala/issues/1188
scala_import(
name = "stamping_first_time",
jars = ["relate_2.11-2.1.1.jar"],
jars = ["//test/src/main/scala/scalarules/test/scala_import/nl:ScalaImportNeverLink"],
)

scala_import(
name = "stamping_second_time",
jars = ["relate_2.11-2.1.1.jar"],
jars = ["//test/src/main/scala/scalarules/test/scala_import/nl:ScalaImportNeverLink"],
)

scala_import_stamping_test_suite(
name = "stamping_tests",
jar = "relate_2.11-2.1.1.jar",
jar = "//test/src/main/scala/scalarules/test/scala_import/nl:ScalaImportNeverLink",
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
load("//scala:scala.bzl", "scala_specs2_junit_test")
load("//scala:scala_import.bzl", "scala_import")
load("@rules_java//java:defs.bzl", "java_library")

java_library(
name = "ScalaImportNeverLink",
srcs = ["ScalaImportNeverLink.java"],
visibility = ["//visibility:public"],
)

scala_import(
name = "scala_import_never_link",
jars = [
"scala_import_never_link.jar",
":ScalaImportNeverLink",
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
],
neverlink = 1,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
package scalarules.test.scala_import.nl;

/**
* This class is packaged in scala_import_never_link.jar
*
* <p>The jar file was created with the following steps:
*
* <p>- javac ScalaImportNeverLink.java - makdir -p scalarules/test/scala_import/nl - mv
* ScalaImportNeverLink.class scalarules/test/scala_import/nl - jar cf scala_import_never_link.jar
* scalarules - rm -fr scalarules ScalaImportNeverLink.class
*
* <p>To stage the updated jar: git add -f scala_import_never_link.jar
*/
public class ScalaImportNeverLink {}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
load("@rules_java//java:defs.bzl", "java_import")
load("//thrift:thrift.bzl", "thrift_library")

java_import(
name = "barejar",
jars = ["bare-thrift.jar"],
visibility = ["//visibility:public"],
)

thrift_library(
name = "bare_jar_thrifts",
external_jars = [
":barejar",
],
srcs = ["//test/src/main/resources/scalarules/test:Foo.thrift"],
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
visibility = ["//visibility:public"],
deps = [
"//test/src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ load("//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bare_jar_1",
external_jars = [
"bare-thrift-1.jar",
],
srcs = ["//test/src/main/resources/scalarules/test:Bar.thrift"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above. Do you know why the second test is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I reference .jar directly
the second test is meant for test_version.sh, apparently every test running against various versions has its copy there

visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ load("//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bare_jar_2",
external_jars = [
"bare-thrift-2.jar",
],
srcs = ["//test/src/main/resources/scalarules/test:Baz.thrift"],
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports_files([
"Foo.thrift",
"Bar.thrift",
"Baz.thrift",
])
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Bar {
1: optional string Bar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Baz {
1: optional string Baz
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace java com.foo.bar.baz

struct Foo {
1: optional string foo
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
load("@rules_java//java:defs.bzl", "java_import")
load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

java_import(
name = "barejar",
jars = ["bare-thrift.jar"],
visibility = ["//visibility:public"],
)

thrift_library(
name = "bare_jar_thrifts",
external_jars = [
":barejar",
],
srcs = ["//src/main/resources/scalarules/test:Foo.thrift"],
visibility = ["//visibility:public"],
deps = [
"//src/main/scala/scalarules/test/twitter_scrooge/thrift/bare_jar_thrifts/bare_jar_1",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bare_jar_1",
external_jars = [
"bare-thrift-1.jar",
],
srcs = ["//src/main/resources/scalarules/test:Bar.thrift"],
visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bare_jar_2",
external_jars = [
"bare-thrift-2.jar",
],
srcs = ["//src/main/resources/scalarules/test:Baz.thrift"],
visibility = ["//visibility:public"],
)
Binary file not shown.