Commit 113777ba authored by Aya ElAttar's avatar Aya ElAttar Committed by Chromium LUCI CQ

DLP: Support Warn in DlpRulesManager

- Added warn as one of the restriction levels,
and add the required unittests.
- Renamed the urls and patterns in the unittests
to reduce confusion.

Bug: 1169080
Change-Id: I806d1fb7aa8a4c94cd47b02e5be3a8636b2e26ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642776
Commit-Queue: Aya Elsayed <ayaelattar@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846038}
parent 3d1a3f3e
...@@ -23,6 +23,7 @@ constexpr char kPluginVm[] = "PLUGIN_VM"; ...@@ -23,6 +23,7 @@ constexpr char kPluginVm[] = "PLUGIN_VM";
constexpr char kAllowLevel[] = "ALLOW"; constexpr char kAllowLevel[] = "ALLOW";
constexpr char kBlockLevel[] = "BLOCK"; constexpr char kBlockLevel[] = "BLOCK";
constexpr char kWarnLevel[] = "WARN";
} // namespace dlp } // namespace dlp
......
...@@ -48,7 +48,8 @@ class DlpRulesManager : public KeyedService { ...@@ -48,7 +48,8 @@ class DlpRulesManager : public KeyedService {
kNotSet, // Restriction level is not set. kNotSet, // Restriction level is not set.
kBlock, // Sets the restriction level to block the user on every action. kBlock, // Sets the restriction level to block the user on every action.
kAllow, // Sets the restriction level to allow (no restriction). kAllow, // Sets the restriction level to allow (no restriction).
kMaxValue = kAllow kWarn, // Sets the restriction level to warn the user on every action.
kMaxValue = kWarn
}; };
~DlpRulesManager() override = default; ~DlpRulesManager() override = default;
......
...@@ -52,7 +52,8 @@ DlpRulesManager::Level GetLevelMapping(const std::string& level) { ...@@ -52,7 +52,8 @@ DlpRulesManager::Level GetLevelMapping(const std::string& level) {
static constexpr auto kLevelsMap = static constexpr auto kLevelsMap =
base::MakeFixedFlatMap<base::StringPiece, DlpRulesManager::Level>( base::MakeFixedFlatMap<base::StringPiece, DlpRulesManager::Level>(
{{dlp::kAllowLevel, DlpRulesManager::Level::kAllow}, {{dlp::kAllowLevel, DlpRulesManager::Level::kAllow},
{dlp::kBlockLevel, DlpRulesManager::Level::kBlock}}); {dlp::kBlockLevel, DlpRulesManager::Level::kBlock},
{dlp::kWarnLevel, DlpRulesManager::Level::kWarn}});
auto* it = kLevelsMap.find(level); auto* it = kLevelsMap.find(level);
return (it == kLevelsMap.end()) ? DlpRulesManager::Level::kNotSet return (it == kLevelsMap.end()) ? DlpRulesManager::Level::kNotSet
: it->second; : it->second;
...@@ -75,8 +76,9 @@ uint8_t GetPriorityMapping(const DlpRulesManager::Level level) { ...@@ -75,8 +76,9 @@ uint8_t GetPriorityMapping(const DlpRulesManager::Level level) {
static constexpr auto kPrioritiesMap = static constexpr auto kPrioritiesMap =
base::MakeFixedFlatMap<DlpRulesManager::Level, uint8_t>( base::MakeFixedFlatMap<DlpRulesManager::Level, uint8_t>(
{{DlpRulesManager::Level::kNotSet, 0}, {{DlpRulesManager::Level::kNotSet, 0},
{DlpRulesManager::Level::kBlock, 1}, {DlpRulesManager::Level::kWarn, 1},
{DlpRulesManager::Level::kAllow, 2}}); {DlpRulesManager::Level::kBlock, 2},
{DlpRulesManager::Level::kAllow, 3}});
return kPrioritiesMap.at(level); return kPrioritiesMap.at(level);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment