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
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
18 changes: 10 additions & 8 deletions test/example_jars/BUILD
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
load("@rules_java//java:defs.bzl", "java_import")
load("//scala:scala.bzl", "scala_library")

java_import(
scala_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(
scala_library(
name = "example_jar2",
jars = [
"example_jar2.jar",
],
resource_strip_prefix = "{}/{}".format(
package_name(),
"src/main/resources",
),
resources = ["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.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.beam.sdk.io.LocalFileSystemRegistrar
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.
23 changes: 21 additions & 2 deletions test/src/main/scala/scalarules/test/resource_jars/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
load("//scala:scala.bzl", "scala_test")
load("//scala:scala.bzl", "scala_library", "scala_test")
load("//scala:scala_import.bzl", "scala_import")

scala_library(
name = "jar_with_resources",
testonly = True,
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",
],
)

scala_import(
name = "imported_jar_with_resources",
jars = [
":jar_with_resources.jar",
],
)

scala_test(
name = "resource_jars",
srcs = ["TestResourceJars.scala"],
resource_jars = ["//test/src/main/resources/scalarules/test:hellos-and-byes.jar"],
resource_jars = [":imported_jar_with_resources"],
)
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
20 changes: 13 additions & 7 deletions test/src/main/scala/scalarules/test/scala_import/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ scala_import(
],
)

# Jars as files
scala_library(
name = "generic_scalalib",
testonly = True,
srcs = ["generic/Generic.scala"],
visibility = ["//visibility:private"],
)

scala_import(
name = "relate",
name = "imported_genericlib_jar",
jars = [
"relate_2.11-2.1.1.jar",
":generic_scalalib.jar",
],
)

Expand All @@ -41,7 +47,7 @@ scala_specs2_junit_test(
size = "small",
srcs = ["ScalaImportExposesFileJarsTest.scala"],
suffixes = ["Test"],
deps = [":relate"],
deps = [":imported_genericlib_jar"],
)

scala_library(
Expand Down Expand Up @@ -123,15 +129,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:libscala_import_never_link.jar"],
)

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

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:libscala_import_never_link.jar",
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package scalarules.test.scala_import

import scalarules.test.scala_import.generic.Generic

import org.specs2.mutable.SpecificationWithJUnit
import com.lucidchart.relate.SqlRow

class ScalaImportExposesJarsTest extends SpecificationWithJUnit {

"scala_import" >> {
"enable importing jars from files" in {
println(classOf[SqlRow])
assert(Generic.foo == "bar")
success
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package scalarules.test.scala_import.generic

object Generic {
val foo = "bar"
}
13 changes: 10 additions & 3 deletions test/src/main/scala/scalarules/test/scala_import/nl/BUILD.bazel
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")

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

scala_import(
name = "imported_scala_import_never_link",
jars = [
"scala_import_never_link.jar",
":libscala_import_never_link.jar",
],
neverlink = 1,
)
Expand All @@ -14,5 +21,5 @@ scala_specs2_junit_test(
size = "small",
srcs = ["ScalaImportNeverLinkTest.scala"],
suffixes = ["Test"],
deps = [":scala_import_never_link"],
deps = [":imported_scala_import_never_link"],
)
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,16 +1,14 @@
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 = "foo",
srcs = ["//test/src/main/resources/scalarules/test:Foo.thrift"],
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
)

thrift_library(
name = "bare_jar_thrifts",
external_jars = [
":barejar",
":libfoo.jar",
],
visibility = ["//visibility:public"],
deps = [
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
load("//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bar",
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

)

thrift_library(
name = "bare_jar_1",
external_jars = [
"bare-thrift-1.jar",
":libbar.jar",
],
visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
load("//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "baz",
srcs = ["//test/src/main/resources/scalarules/test:Baz.thrift"],
mateuszkuta256 marked this conversation as resolved.
Show resolved Hide resolved
)

thrift_library(
name = "bare_jar_2",
external_jars = [
"bare-thrift-2.jar",
":libbaz.jar",
],
visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ thrift_library(
visibility = ["//visibility:public"],
)

# "thrift3_import" is a dependency of another scala library which checks whether "Struct3" from above "Thrift3" thrift
# is imported properly via: "import scalarules.test.twitter_scrooge.thrift.thrift2.thrift3.Struct3"

scrooge_scala_import(
name = "thrift3_import",
scala_jars = ["thrift3_scrooge.jar"],
scala_jars = ["//test/src/main/scala/scalarules/test/twitter_scrooge:scrooge3"],
thrift_jars = ["libthrift3.jar"],
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,16 +1,14 @@
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 = "foo",
srcs = ["//src/main/resources/scalarules/test:Foo.thrift"],
)

thrift_library(
name = "bare_jar_thrifts",
external_jars = [
":barejar",
":libfoo.jar",
],
visibility = ["//visibility:public"],
deps = [
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "bar",
srcs = ["//src/main/resources/scalarules/test:Bar.thrift"],
)

thrift_library(
name = "bare_jar_1",
external_jars = [
"bare-thrift-1.jar",
":libbar.jar",
],
visibility = ["//visibility:public"],
)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
load("@io_bazel_rules_scala//thrift:thrift.bzl", "thrift_library")

thrift_library(
name = "baz",
srcs = ["//src/main/resources/scalarules/test:Baz.thrift"],
)

thrift_library(
name = "bare_jar_2",
external_jars = [
"bare-thrift-2.jar",
":libbaz.jar",
],
visibility = ["//visibility:public"],
)
Binary file not shown.
Loading