diff options
author | 2017-05-16 21:41:39 +0200 | |
---|---|---|
committer | 2017-05-17 15:21:04 +0200 | |
commit | 9e255ef45c4928eb167c1f24756cb7ab435914e5 (patch) | |
tree | c835baaf52f6d6e3278e5d4e74ef858a7d4e3f5a /src/test/java/com/google/devtools/build/lib/rules/config | |
parent | 21fd43e8b66df9d6e06dee31c1f05a8440df6342 (diff) |
Fix minor hashing bug in config_feature_flag configuration name.
Previously, it was possible to have
//package:foo : barbaz
and
//package:foobar : baz
hash to the same value, making it very easy for users to cause a hash
collision by accident. This adds a zero byte after each string so that the
hash will differentiate the two.
RELNOTES: None.
PiperOrigin-RevId: 156216723
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/rules/config')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfigurationTest.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfigurationTest.java index a0de77dfdf..5034db2d25 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfigurationTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/config/ConfigFeatureFlagConfigurationTest.java @@ -217,6 +217,20 @@ public final class ConfigFeatureFlagConfigurationTest { } @Test + public void getOutputDirectoryName_differentiatesLabelAndValue() throws Exception { + Map<Label, String> someFlags = + ImmutableMap.of( + Label.parseAbsoluteUnchecked("//a:a"), "firestarter", + Label.parseAbsoluteUnchecked("//b:b"), "second"); + Map<Label, String> otherFlags = + ImmutableMap.of( + Label.parseAbsoluteUnchecked("//a:afire"), "starter", + Label.parseAbsoluteUnchecked("//b:b"), "second"); + assertThat(getConfigurationWithFlags(otherFlags).getOutputDirectoryName()) + .isNotEqualTo(getConfigurationWithFlags(someFlags).getOutputDirectoryName()); + } + + @Test public void getOutputDirectoryName_returnsDifferentValueForSubsetOfFlagValuePairs() throws Exception { Map<Label, String> someFlags = ImmutableMap.of(Label.parseAbsoluteUnchecked("//a:a"), "first"); |