Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename to tirith #76

Merged
merged 4 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased] - Unreleased

### Fixed

- Terraform binary not required for using OPA provider



## [v1.0-beta.2] - 2021-01-12

### Added

- CHANGELOG, CODE_OF_CONDUCT, CONTRIBUTING
- Adopted Covenant Code of Conduct
- cli wrapper for calling sg_policy
- cli wrapper for calling tirith
- Summarized evaluation output and provides brief output formatting

### Fixed

- License content


## [v1.0-beta.1] - 2021-07-10

- Initial release of SG Policy Framework.
- Initial release of Tirith (SG Policy Framework).
- New schema for policy declaration in JSON - V1.BETA
- Tested for scanning terraform plans >= 0.14.6
- Added Support for for evaluations using Rego:
> - str_equals_str
> - str_contains_str
> - str_contains_str
> - equals_null
> - str_matches_regex
> - bool_equals_bool
> - cidr_contains_cidr_or_ip
> - str_equals_str
> - str_contains_str
> - str_contains_str
> - equals_null
> - str_matches_regex
> - bool_equals_bool
> - cidr_contains_cidr_or_ip

---

-------------
## Types of changes

**Added**: for new features.

**Changed**: for changes in existing functionality.
Expand All @@ -53,7 +54,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

**Security**: in case of vulnerabilities.


[Unreleased]: https://github.com/StackGuardian/policy-framework/compare/v1.0-beta.2...HEAD
[v1.0-beta.1]: https://github.com/StackGuardian/policy-framework/compare/v1.0-beta.1
[v1.0-beta.2]: https://github.com/StackGuardian/policy-framework/compare/v1.0-beta.2
[unreleased]: https://github.com/StackGuardian/tirith/compare/v1.0-beta.2...HEAD
[v1.0-beta.1]: https://github.com/StackGuardian/tirith/compare/v1.0-beta.1
[v1.0-beta.2]: https://github.com/StackGuardian/tirith/compare/v1.0-beta.2
23 changes: 11 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
# Contributing to StackGuardian Policy Framework
# Contributing to Tirith (StackGuardian Policy Framework)

Thank you for taking the time to contribute! 🎉
Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.

The following is a set of guidelines for contributing to StackGuardian Policy Framework on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
The following is a set of guidelines for contributing to Tirith on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.

## Contribution types

### Report Bugs

We use GitHub issues to track bugs at [https://github.com/stackguardian/policy-framework/issues](https://github.com/stackguardian/policy-framework/issues). Please use Bug report issue template.
We use GitHub issues to track bugs at [https://github.com/stackguardian/tirith/issues](https://github.com/stackguardian/tirith/issues). Please use Bug report issue template.

### Fix Bugs and implement features

All contributions to solve GitHub issues tagged with "bug", "enhancement" and "help wanted" are most welcome and greatly appreciated.

### Documentation

StackGuardian Policy Framework could always use more documentation, whether as part of the
official StackGuardian Policy Framework docs, in docstrings, or even on the web in blog posts,
Trith could always use more documentation, whether as part of the
official Tirith docs, in docstrings, or even on the web in blog posts,
articles, and such.

### Submit Feedback

Please use GitHub Discussions to submit feedback and engage with community [https://github.com/StackGuardian/feedback/discussions/8](https://github.com/StackGuardian/feedback/discussions/8).


## Basic guidelines

For all changes you commit or submit by pull-request please follow these simple guidelines:

### Advice on pull requests:

* Raise Pull Request as soon as you start working on a feature, bug, test or hotfix and label it with `work-in-progress`, while it is not ready to be merged.
* Commits or squashed commits in your pull-requests should have a useful description.
* Always update CHANGELOG.md before merging Pull Requests.
- Raise Pull Request as soon as you start working on a feature, bug, test or hotfix and label it with `work-in-progress`, while it is not ready to be merged.
- Commits or squashed commits in your pull-requests should have a useful description.
- Always update CHANGELOG.md before merging Pull Requests.

### If you have commit access:

* Do NOT use git push --force.
* Do NOT commit to other contributor's branches without their consent.
* Use Pull Requests if you are unsure and to suggest changes to other maintainers.
- Do NOT use git push --force.
- Do NOT commit to other contributor's branches without their consent.
- Use Pull Requests if you are unsure and to suggest changes to other maintainers.
12 changes: 6 additions & 6 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=StackGuardian_policy-framework&metric=alert_status&token=4a4d06e73940505edb7fc9d27a7f03b35fbbf23d)](https://sonarcloud.io/summary/new_code?id=StackGuardian_policy-framework)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=StackGuardian_policy-framework&metric=sqale_rating&token=4a4d06e73940505edb7fc9d27a7f03b35fbbf23d)](https://sonarcloud.io/summary/new_code?id=StackGuardian_policy-framework)

# StackGuardian Policy Framework
# Tirith (StackGuardian Policy Framework)

## A call for contributors

We are calling for contributors to help build out new features, review pull requests, fix bugs, and maintain overall code quality. If you're interested, please email us at team[at]stackguardian.io or get started by reading the [contributing.md](./CONTRIBUTING.md).

StackGuardian Policy Framework scans declarative Infrastructure as Code (IaC) configurations like Terraform against policies defined using JSON.
Tirith scans declarative Infrastructure as Code (IaC) configurations like Terraform against policies defined using JSON.

## Content

Expand All @@ -36,7 +36,7 @@ StackGuardian Policy Framework scans declarative Infrastructure as Code (IaC) co

## Feature Road-map

This is only a list of approved features that will be included in the StackGuardian Policy Framework over the next few months.
This is only a list of approved features that will be included in Tirith over the next few months.

- Support for CloudFormation config scanning
- Support for ARM config scanning
Expand Down Expand Up @@ -76,24 +76,24 @@ And leave the rest to us!!!

### Getting an issue assigned

Go to the <a href="https://github.com/StackGuardian/policy-framework">StackGuardian Policy Framework Repository</a> and in the <a href="https://github.com/stackguardian/policy-framework/issues">issues</a> tab describe any bug or feature you want to add. If found relevant, the maintainers will assign the issue to you and you may start working on it as mentioned in the next section.
Go to the <a href="https://github.com/StackGuardian/tirith">Tirith Repository</a> and in the <a href="https://github.com/stackguardian/tirith/issues">issues</a> tab describe any bug or feature you want to add. If found relevant, the maintainers will assign the issue to you and you may start working on it as mentioned in the next section.

<p>The kinds of issues a contributor can open:</p>
<ul>
<li>Report Bugs</li>
<li>Feature Enhancement</li>
<li>If any "help" is needed with the policy framework</li>
<li>If any "help" is needed with using Tirith</li>
</ul>

### A bug report

Head over to the <a href="https://github.com/StackGuardian/policy-framework">StackGuardian Policy Framework Repository</a> and in the <a href="https://github.com/stackguardian/policy-framework/issues">issues</a> tab describe the bug you encountered and we will be happy to take a look into it.
Head over to the <a href="https://github.com/StackGuardian/tirith">Tirith repository</a> and in the <a href="https://github.com/stackguardian/tirith/issues">issues</a> tab describe the bug you encountered and we will be happy to take a look into it.

### Opening a Pull Request and getting it merged?

1. Go to the <a href ="https://github.com/StackGuardian/policy-framework">repository</a> and fork it.
1. Go to the <a href ="https://github.com/StackGuardian/tirith">repository</a> and fork it.
2. Clone the repository in your local machine.
3. Open your terminal and `cd policy-framework`
3. Open your terminal and `cd tirith`
4. Create your own branch to work on the changes you intend to perform. For e.g. if you want some changes or bug fix to any function in the evaluators, name your branch with something relevant like, `git branch bug-fix-equals-evaluator`
5. After necessary changes, `git push --set-upstream origin bug-fix-equals-evaluator`, `git checkout main` and `git merge bug-fix-equals-evaluator` or use the GUI to create a "Pull Request" after pushing it in the respective branch.
6. A review request will be sent to the repository maintainers and your changes will be merged if found relevant.
Expand Down
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def read(*names, **kwargs):


setup(
name="sg_policy",
name="tirith",
version="1.0.0-alpha.1",
license="Apache",
description="StackGuardian Policy Framework simplifies defining Policy as Code.",
description="Tirith simplifies defining Policy as Code.",
long_description_content_type="text/markdown",
long_description="%s\n%s"
% (
Expand All @@ -33,7 +33,7 @@ def read(*names, **kwargs):
),
author="StackGuardian",
author_email="team@stackguardian.io",
url="https://github.com/stackguardian/policy-framework",
url="https://github.com/stackguardian/tirith",
packages=find_packages("src"),
package_dir={"": "src"},
py_modules=[splitext(basename(path))[0] for path in glob("src/*.py")],
Expand Down Expand Up @@ -64,8 +64,8 @@ def read(*names, **kwargs):
"Topic :: System",
],
project_urls={
"Changelog": "https://github.com/stackguardian/policy-framework/blob/main/CHANGELOG.md",
"Issue Tracker": "https://github.com/stackguardian/policy-framework/issues",
"Changelog": "https://github.com/stackguardian/tirith/blob/main/CHANGELOG.md",
"Issue Tracker": "https://github.com/stackguardian/tirith/issues",
},
keywords=["iac", "policy", "terraform", "policy as code"],
python_requires=">=3.8.*",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also need to renew the install_requires to match Pipfile content, e.g. if people were to install this using pip install tirith (assumming we will use the name tirith in pypi) it will only install the deps listed in install_requires in this setup.py, not from the pipfile. Good way to test this is to create a new venv and do pip install . to see what it installs

A good tool to automate this is pypa/pipenv#1263 (comment)

Otherwise just writing it down manually is OK as well because our Pipfile currently only has 2 deps

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be done in a separate PR though

Expand All @@ -80,7 +80,7 @@ def read(*names, **kwargs):
],
entry_points={
"console_scripts": [
"sg_policy=sg_policy.__main__:main",
"tirith=tirith.__main__:main",
]
},
)
2 changes: 1 addition & 1 deletion src/sg_policy/__init__.py → src/tirith/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
sg_policy: Execute policies defined using StackGuardian Policy Framework
tirith: Execute policies defined using Tirith (StackGuardian Policy Framework)
"""

__version__ = "1.0.0-alpha.1"
Expand Down
4 changes: 2 additions & 2 deletions src/sg_policy/__main__.py → src/tirith/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Entrypoint module when invoked like `python -m sg_policy`.
Entrypoint module when invoked like `python -m tirith`.
"""
import sys

Expand All @@ -11,7 +11,7 @@ def main():

exit_status = main()
except KeyboardInterrupt:
from sg_policy.status import ExitStatus
from tirith.status import ExitStatus

exit_status = ExitStatus.ERROR_CTRL_C

Expand Down
28 changes: 14 additions & 14 deletions src/sg_policy/cli.py → src/tirith/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import sys
import textwrap

import sg_policy.providers.terraform_plan.handler as python_tf_plan_handler
from sg_policy.logging import setup_logging
from sg_policy.prettyprinter import pretty_print_result_dict
from sg_policy.status import ExitStatus
import tirith.providers.terraform_plan.handler as python_tf_plan_handler
from tirith.logging import setup_logging
from tirith.prettyprinter import pretty_print_result_dict
from tirith.status import ExitStatus

from .core import start_policy_evaluation

Expand Down Expand Up @@ -43,27 +43,27 @@ def __init__(self, prog="PROG") -> None:
super().__init__(prog, max_help_position=300)

parser = argparse.ArgumentParser(
description="StackGuardian Policy Framework.",
description="Tirith (StackGuardian Policy Framework)",
formatter_class=_WidthFormatter,
epilog=textwrap.dedent(
"""\
About StackGuardian Policy Framework:
About Tirith:

* Abstract away the implementation complexity of policy engine underneath.
* Simplify creation of declarative policies that are easy to read and interpret.
* Provide a standard framework for scanning various configurations with granularity.
* Provide modularity to enable easy extensibility
* Github - https://github.com/StackGuardian/policy-framework
* Docs - https://docs.stackguardian.io/docs/policy-framework/overview
"""
* Abstract away the implementation complexity of policy engine underneath.
* Simplify creation of declarative policies that are easy to read and interpret.
* Provide a standard framework for scanning various configurations with granularity.
* Provide modularity to enable easy extensibility
* Github - https://github.com/StackGuardian/tirith
* Docs - https://docs.stackguardian.io/docs/tirith/overview
"""
),
)
parser.add_argument(
"-policy-path",
metavar="PATH",
type=str,
dest="policyPath",
help="Path containing policy defined using StackGuardian Policy Framework",
help="Path containing Tirith policy as code",
)
parser.add_argument(
"-input-path",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from .base_evaluator import BaseEvaluator
from sg_policy.utils import sort_collections
from tirith.utils import sort_collections

# TODO: At least add __name__ as the name for the logger
logger = logging.getLogger()
Expand Down Expand Up @@ -85,7 +85,7 @@ def evaluate(self, evaluator_input, evaluator_data):
if result:
evaluation_result["message"] = "Found {} inside {}".format(evaluator_input, evaluator_data)
else:
evaluation_result["message"] = "{} is an unsupported data type for in condition.value".format(
evaluation_result["message"] = "{} is an unsupported data type for evaluating against value in 'condition.value'".format(
evaluator_data
)
return evaluation_result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from .base_evaluator import BaseEvaluator
from sg_policy.utils import sort_collections
from tirith.utils import sort_collections

# TODO: At least add __name__ as the name for the logger
logger = logging.getLogger()
Expand Down Expand Up @@ -85,7 +85,7 @@ def evaluate(self, evaluator_input, evaluator_data):
if result:
evaluation_result["message"] = "Found {} inside {}".format(evaluator_data, evaluator_input)
else:
evaluation_result["message"] = "{} is an unsupported data type for in condition.value".format(
evaluation_result["message"] = "{} is an unsupported data type for evaluating against value in 'condition.value'".format(
evaluator_data
)
return evaluation_result
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from .base_evaluator import BaseEvaluator
from sg_policy.utils import sort_collections
from tirith.utils import sort_collections

# TODO: Use __name__ for the logger name instead of using the root logger
logger = logging.getLogger()
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,4 @@ def pretty_print_result_dict(final_result_dict: Dict) -> None:
elif final_result_dict["final_result"] is None:
print(TermStyle.skipped("= Skipped final evaluator"))
else:
print(TermStyle.fail("✘ Not passed final evaluator"))
print(TermStyle.fail("✘ Failed final evaluation"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the passed and skipped messages should also be changed to use the term "evaluation" instead of "evaluator"

File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/core/evaluators/test_contained_in.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sg_policy.core.evaluators import ContainedIn
from tirith.core.evaluators import ContainedIn
from pytest import mark


Expand Down
2 changes: 1 addition & 1 deletion tests/core/evaluators/test_contains.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from sg_policy.core.evaluators import Contains
from tirith.core.evaluators import Contains
from pytest import mark


Expand Down
Loading