question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config_setting visibility not enforced

See original GitHub issue

Description of the problem / bug:

It should not be allowed to access a private config_setting from select in other package. But bazel fails to enforce the visibility.

Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

pkgA/BUILD:

load(
    "@bazel_skylib//rules:common_settings.bzl",
    "bool_flag",
)

bool_flag(
    name = "myFlag",
    build_setting_default = False,
    # This visibility is working, however the config_setting is in same package.
    visibility = ["//visibility:private"]
)

config_setting(
    name = "mySetting",
    flag_values = {"myFlag": "True"},
    # This can be accessed from pkgB, despite private visibility
    visibility = ["//visibility:private"]
)

pkgB/BUILD:

genrule(
    name = "foo",
    srcs = [],
    outs = ["foo.out"],
    # Can access mySetting from another package, despite private visibility. 
    cmd = select({
        "//pkgA:mySetting": "echo running with mySetting > $@",
        "//conditions:default": "echo running default > $@"}),
)

I expect both of the following commands to fail, due to pkgB accessing private config_setting in pkgA, but no error is detected:

bbi_bazel build //pkgB:foo --//pkgA:myFlag=True
bbi_bazel build //pkgB:foo --//pkgA:myFlag=False

What operating system are you running Bazel on?

Linux

What’s the output of bazel info release?

3.7.0

Have you found anything relevant by searching the web?

I searched, but have not found anything.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gregestrencommented, Jan 29, 2021

Filed bugs for --incompatible_* flags: https://github.com/bazelbuild/bazel/issues/12932. PR using them incoming.

1reaction
gregestrencommented, Jan 29, 2021

FYI: I rolled back my PR because it breaks some projects that already set visibility on config_setting with bad values.

I’m rolling it forward again behind a flag. Stay tuned…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visibility | Bazel
Config setting visibility. Historically, Bazel has not enforced visibility for config_setting targets that are referenced in the keys of a ...
Read more >
visibility-like capability for bzl files (rules, aspects, and macros ...
We are actively interested in (i.e., designing this quarter) a feature for load() -level enforcement of .bzl visibility. This would not ...
Read more >
User email visibility setting should not affect REST responses
In JIRA Server we notice that if a user sets the General Config setting "User email visibility" to Hidden, that is described as...
Read more >
General Config Settings | Craft CMS Documentation | 3.x
To set a new config setting, open config/general.php and define it in one of the ... should not be indexed, and links on...
Read more >
CONFIG SETTING FOR DATUM FILTERS? - PTC Community
Hey all, I am trying to see if there is a config setting that will leave the ... how to get layer rules...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found