Skip to content

Commit d2ebac4

Browse files
alyssawilkchaoqinli
authored and
chaoqinli
committed
build: marking extensions as extension-only visible by default (envoyproxy#12337)
Risk Level: medium (of build breakage) Testing: n/a Docs Changes: n/a Release Notes: n/a Part of envoyproxy#9953 Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
1 parent 570344e commit d2ebac4

File tree

159 files changed

+586
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+586
-315
lines changed

BUILD

+30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1+
load(
2+
"@envoy_build_config//:extensions_build_config.bzl",
3+
"ADDITIONAL_VISIBILITY",
4+
)
5+
16
licenses(["notice"]) # Apache 2
27

38
exports_files([
49
"VERSION",
510
".clang-format",
611
])
12+
13+
# These two definitions exist to help reduce Envoy upstream core code depending on extensions.
14+
# To avoid visibility problems, one can extend ADDITIONAL_VISIBILITY in source/extensions/extensions_build_config.bzl
15+
#
16+
# TODO(#9953) //test/config_test:__pkg__ should probably be split up and removed.
17+
# TODO(#9953) the config fuzz tests should be moved somewhere local and //test/config_test and //test/server removed.
18+
package_group(
19+
name = "extension_config",
20+
packages = [
21+
"//source/exe",
22+
"//source/extensions/...",
23+
"//test/config_test",
24+
"//test/extensions/...",
25+
"//test/server",
26+
"//test/server/config_validation",
27+
] + ADDITIONAL_VISIBILITY,
28+
)
29+
30+
package_group(
31+
name = "extension_library",
32+
packages = [
33+
"//source/extensions/...",
34+
"//test/extensions/...",
35+
] + ADDITIONAL_VISIBILITY,
36+
)

bazel/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,17 @@ local_repository(
611611
...
612612
```
613613

614+
## Extra extensions
615+
616+
If you are building your own Envoy extensions or custom Envoy builds and encounter visibility
617+
problems with, you may need to adjust the default visibility rules.
618+
By default, Envoy extensions are set up to only be visible to code within the
619+
[//source/extensions](../source/extensions/), or the Envoy server target. To adjust this,
620+
add any additional targets you need to `ADDITIONAL_VISIBILITY` in
621+
[extensions_build_config.bzl](../source/extensions/extensions_build_config.bzl).
622+
See the instructions above about how to create your own custom version of
623+
[extensions_build_config.bzl](../source/extensions/extensions_build_config.bzl).
624+
614625
# Release builds
615626

616627
Release builds should be built in `opt` mode, processed with `strip` and have a

bazel/envoy_build_system.bzl

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ load(
3636
def envoy_package():
3737
native.package(default_visibility = ["//visibility:public"])
3838

39+
def envoy_extension_package():
40+
native.package(default_visibility = ["//:extension_library"])
41+
3942
# A genrule variant that can output a directory. This is useful when doing things like
4043
# generating a fuzz corpus mechanically.
4144
def _envoy_directory_genrule_impl(ctx):

bazel/envoy_library.bzl

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ def envoy_cc_extension(
7070
undocumented = False,
7171
status = "stable",
7272
tags = [],
73+
visibility = ["//:extension_config"],
7374
**kwargs):
7475
if security_posture not in EXTENSION_SECURITY_POSTURES:
7576
fail("Unknown extension security posture: " + security_posture)
7677
if status not in EXTENSION_STATUS_VALUES:
7778
fail("Unknown extension status: " + status)
78-
envoy_cc_library(name, tags = tags, **kwargs)
79+
envoy_cc_library(name, tags = tags, visibility = visibility, **kwargs)
7980

8081
# Envoy C++ library targets should be specified with this function.
8182
def envoy_cc_library(

docs/root/version_history/current.rst

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Incompatible Behavior Changes
55
-----------------------------
66
*Changes that are expected to cause an incompatibility if applicable; deployment changes are likely required*
77

8+
* build: added visibility rules for upstream. If these cause visibility related breakage, see notes in //BUILD.
9+
810
Minor Behavior Changes
911
----------------------
1012
*Changes that may cause incompatibilities for some users, but should not for most*

source/extensions/access_loggers/BUILD

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "well_known_names",
1313
hdrs = ["well_known_names.h"],
14+
# well known names files are public as long as they exist.
15+
visibility = ["//visibility:public"],
1416
deps = [
1517
"//source/common/singleton:const_singleton",
1618
],

source/extensions/access_loggers/common/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

99
# Base class for implementations of AccessLog::Instance.
1010

11-
envoy_package()
11+
envoy_extension_package()
1212

1313
envoy_cc_library(
1414
name = "access_log_base",

source/extensions/access_loggers/file/BUILD

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@ load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
44
"envoy_cc_library",
5-
"envoy_package",
5+
"envoy_extension_package",
66
)
77

88
licenses(["notice"]) # Apache 2
99

1010
# Access log implementation that writes to a file.
1111
# Public docs: docs/root/configuration/access_log.rst
1212

13-
envoy_package()
13+
envoy_extension_package()
1414

1515
envoy_cc_library(
1616
name = "file_access_log_lib",
1717
srcs = ["file_access_log_impl.cc"],
1818
hdrs = ["file_access_log_impl.h"],
19+
# The file based access logger is core code.
20+
visibility = ["//visibility:public"],
1921
deps = [
2022
"//source/extensions/access_loggers/common:access_log_base",
2123
],
@@ -26,6 +28,11 @@ envoy_cc_extension(
2628
srcs = ["config.cc"],
2729
hdrs = ["config.h"],
2830
security_posture = "robust_to_untrusted_downstream",
31+
# TODO(#9953) determine if this is core or should be cleaned up.
32+
visibility = [
33+
"//:extension_config",
34+
"//test:__subpackages__",
35+
],
2936
deps = [
3037
":file_access_log_lib",
3138
"//include/envoy/registry",

source/extensions/access_loggers/grpc/BUILD

+14-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
44
"envoy_cc_library",
5-
"envoy_package",
5+
"envoy_extension_package",
66
)
77

88
licenses(["notice"]) # Apache 2
99

1010
# Access log implementation that writes to a gRPC service.
1111
# Public docs: TODO(rodaine): Docs needed.
1212

13-
envoy_package()
13+
envoy_extension_package()
1414

1515
envoy_cc_library(
1616
name = "config_utils",
@@ -98,6 +98,12 @@ envoy_cc_extension(
9898
srcs = ["http_config.cc"],
9999
hdrs = ["http_config.h"],
100100
security_posture = "robust_to_untrusted_downstream",
101+
# TODO(#9953) clean up.
102+
visibility = [
103+
"//:extension_config",
104+
"//test/common/access_log:__subpackages__",
105+
"//test/integration:__subpackages__",
106+
],
101107
deps = [
102108
":config_utils",
103109
"//include/envoy/server:access_log_config_interface",
@@ -115,6 +121,12 @@ envoy_cc_extension(
115121
srcs = ["tcp_config.cc"],
116122
hdrs = ["tcp_config.h"],
117123
security_posture = "robust_to_untrusted_downstream",
124+
# TODO(#9953) clean up.
125+
visibility = [
126+
"//:extension_config",
127+
"//test/common/access_log:__subpackages__",
128+
"//test/integration:__subpackages__",
129+
],
118130
deps = [
119131
":config_utils",
120132
"//include/envoy/server:access_log_config_interface",

source/extensions/clusters/BUILD

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "well_known_names",
1313
hdrs = ["well_known_names.h"],
14+
# well known names files are public as long as they exist.
15+
visibility = ["//visibility:public"],
1416
deps = [
1517
"//source/common/config:well_known_names",
1618
"//source/common/singleton:const_singleton",

source/extensions/clusters/aggregate/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_extension(
1212
name = "cluster",

source/extensions/clusters/dynamic_forward_proxy/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_extension(
1212
name = "cluster",

source/extensions/clusters/redis/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
44
"envoy_cc_library",
5-
"envoy_package",
5+
"envoy_extension_package",
66
)
77

88
licenses(["notice"]) # Apache 2
99

10-
envoy_package()
10+
envoy_extension_package()
1111

1212
envoy_cc_library(
1313
name = "crc16_lib",

source/extensions/common/BUILD

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "utility_lib",
1313
hdrs = ["utility.h"],
14+
# Legacy. TODO(#9953) clean up.
15+
visibility = ["//visibility:public"],
1416
deps = [
1517
"//include/envoy/runtime:runtime_interface",
1618
"//source/common/common:documentation_url_lib",

source/extensions/common/aws/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "signer_interface",

source/extensions/common/crypto/BUILD

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_extension",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_extension(
1212
name = "utility_lib",
@@ -23,6 +23,12 @@ envoy_cc_extension(
2323
],
2424
security_posture = "unknown",
2525
undocumented = True,
26+
# Legacy test use. TODO(#9953) clean up.
27+
visibility = [
28+
"//:extension_config",
29+
"//test/common/config:__subpackages__",
30+
"//test/common/crypto:__subpackages__",
31+
],
2632
deps = [
2733
"//include/envoy/buffer:buffer_interface",
2834
"//source/common/common:assert_lib",

source/extensions/common/dynamic_forward_proxy/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "dns_cache_interface",

source/extensions/common/proxy_protocol/BUILD

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
88

9-
envoy_package()
9+
envoy_extension_package()
1010

1111
envoy_cc_library(
1212
name = "proxy_protocol_header_lib",
1313
srcs = ["proxy_protocol_header.cc"],
1414
hdrs = ["proxy_protocol_header.h"],
15+
# This is used by the router, so considered core code.
16+
visibility = ["//visibility:public"],
1517
deps = [
1618
"//include/envoy/buffer:buffer_interface",
1719
"//include/envoy/network:address_interface",

source/extensions/common/redis/BUILD

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load(
22
"//bazel:envoy_build_system.bzl",
33
"envoy_cc_library",
4-
"envoy_package",
4+
"envoy_extension_package",
55
)
66

77
licenses(["notice"]) # Apache 2
@@ -10,7 +10,7 @@ licenses(["notice"]) # Apache 2
1010
# clusters.
1111
# Public docs: docs/root/configuration/network_filters/redis_proxy_filter.rst
1212

13-
envoy_package()
13+
envoy_extension_package()
1414

1515
envoy_cc_library(
1616
name = "cluster_refresh_manager_interface",

0 commit comments

Comments
 (0)