-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Slim down the SQL policy verifier and separate it from datalog_policy…
…_verifier. In the early days of Raksha, we created the `datalog_policy_verifier`. This was before we understood that the Souffle language and the Souffle internal architecture meant that we would have to create a separate library per policy interface, and that having one Souffle library to serve all of our needs probably wasn't going to cut it. Others coming to the Raksha project saw the name and, quite reasonably, believed it was the generic Raksha analysis rather than a SQL-verifier-specific analysis. Attempts to use this library as a generic policy library made it bloated and tangled. This commit attempts to move us to a better state by separating out the SQL policy verifier into a separate `sql_policy_verifier_interface` and associated `sql_policy_verifier`. This allows slimming down that library and extracting it from the tangle. The `datalog_policy_verifier` is now not used for any production purpose, and we can clean it up at our leisure. Fixes #747 See #728 PiperOrigin-RevId: 479677692
- Loading branch information
Showing
8 changed files
with
148 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//----------------------------------------------------------------------------- | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
//----------------------------------------------------------------------------- | ||
|
||
#ifndef SRC_ANALYSIS_SOUFFLE_SQL_POLICY_VERIFIER_INTERFACE | ||
#define SRC_ANALYSIS_SOUFFLE_SQL_POLICY_VERIFIER_INTERFACE | ||
|
||
#include "src/analysis/souffle/sql_output.dl" | ||
#include "src/analysis/souffle/tag_transforms.dl" | ||
#include "src/analysis/souffle/taint.dl" | ||
|
||
// An interface used for running and getting results from the policy verifier for | ||
// the specific purpose of the SQL verifier. | ||
// Does not concern itself with authorization logic facts, considers only | ||
// `Operation`s and `SqlPolicyRule`s. Returns as output the violatesPolicy | ||
// relation, which indicates whether there were failures in a way that is easy | ||
// to read across the Souffle C++ interface. | ||
.input isOperation(delimiter=";") | ||
.input isSqlPolicyRule(delimiter=";") | ||
.output violatesPolicy(delimiter=";") | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//----------------------------------------------------------------------------- | ||
// Copyright 2022 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
//---------------------------------------------------------------------------- | ||
#ifndef SRC_BACKENDS_POLICY_ENGINE_CATCHALL_POLICY_RULE_POLICY_H_ | ||
#define SRC_BACKENDS_POLICY_ENGINE_CATCHALL_POLICY_RULE_POLICY_H_ | ||
|
||
#include <filesystem> | ||
#include <optional> | ||
|
||
#include "absl/strings/string_view.h" | ||
#include "src/backends/policy_engine/policy.h" | ||
|
||
namespace raksha::backends::policy_engine { | ||
|
||
// We ended up in a dependency mess around the SqlPolicyRulePolicy, where a | ||
// number of test frontends started using it that had nothing to do with SQL. | ||
// This is a shim to slim down the SQL infrastructure and allow us to eventually | ||
// eliminate the tests using this as a catchall policy. | ||
class CatchallPolicyRulePolicy : public Policy { | ||
public: | ||
explicit CatchallPolicyRulePolicy(std::string is_sql_policy_rule_facts) | ||
: is_sql_policy_rule_facts_(std::move(is_sql_policy_rule_facts)) {} | ||
|
||
std::string GetPolicyAnalysisCheckerName() const override { | ||
return "datalog_policy_verifier_cxx"; | ||
} | ||
|
||
std::optional<std::string> GetPolicyFactName() const override { | ||
return "isSqlPolicyRule"; | ||
} | ||
|
||
std::optional<std::string> GetPolicyString() const override { | ||
return is_sql_policy_rule_facts_; | ||
} | ||
|
||
private: | ||
std::string is_sql_policy_rule_facts_; | ||
}; | ||
|
||
} // namespace raksha::backends::policy_engine | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters