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

228 add rule audit comment #229

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0bfb61c
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
5a1ebe2
bumped version for testing
ntwrkguru Jun 2, 2021
ee513f6
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
5c25a28
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
24f86ef
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
fd19cff
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
bb7db29
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
e6d20e4
removing .vscode
ntwrkguru Jun 3, 2021
f4897da
bumped to pan-os-python 1.1.0 and added tests
ntwrkguru Jun 3, 2021
27f13bd
Adding rule audit comment support - fixes #228
ntwrkguru Jun 2, 2021
7e2e06b
Merge branch 'develop' of github.com:ntwrkguru/pan-os-ansible into de…
ntwrkguru Jun 3, 2021
2888656
228 formatted per lint test results
ntwrkguru Jun 7, 2021
e9a9dab
228 reverted galaxy.yml collection semver
ntwrkguru Jun 7, 2021
d872d55
Merge branch 'develop' of github.com:PaloAltoNetworks/pan-os-ansible …
ntwrkguru Jun 9, 2021
65a5330
Merge branch 'develop' into 228-add-rule-audit-comment
ntwrkguru Jun 14, 2021
9a54aeb
Adding rule audit comment support - fixes #228
ntwrkguru Jun 2, 2021
44a647a
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
12ec158
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
f397a45
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
ae52b5c
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
e882ed6
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
7deed21
Adding rule audit comment - #228
ntwrkguru Jun 2, 2021
7aa1f7e
removing .vscode
ntwrkguru Jun 3, 2021
4277a14
bumped to pan-os-python 1.1.0 and added tests
ntwrkguru Jun 3, 2021
9fccd1d
228 formatted per lint test results
ntwrkguru Jun 7, 2021
02c0722
228 reverted galaxy.yml collection semver
ntwrkguru Jun 7, 2021
abb2b4c
Merge branch '228-add-rule-audit-comment' of github.com:ntwrkguru/pan…
ntwrkguru Jun 14, 2021
1580b5a
228: final cleanup
ntwrkguru Jun 14, 2021
ac2b624
chore: Fix merge conflict
Jun 14, 2021
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ ENV/
# PyCharm / IntelliJ
.idea

# VS Code
.vscode

ntwrkguru marked this conversation as resolved.
Show resolved Hide resolved
# Configtree diagram generated by sphinx
docs/_diagrams

Expand Down
8 changes: 0 additions & 8 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ else ifneq (ansible_collections,$(toplevel))
endif

python_version := $(shell \
python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))' \
python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))' \
)


Expand Down
12 changes: 11 additions & 1 deletion plugins/modules/panos_security_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@
description:
- Exclude this rule from the listed firewalls in Panorama.
type: bool
audit_comment:
description:
- Add an audit comment to the rule being defined.
type: str
"""

EXAMPLES = """
Expand Down Expand Up @@ -338,7 +342,7 @@

try:
from panos.errors import PanDeviceError
from panos.policies import SecurityRule
from panos.policies import RuleAuditComment, SecurityRule
except ImportError:
try:
from pandevice.errors import PanDeviceError
Expand Down Expand Up @@ -410,6 +414,7 @@ def main():
location=dict(choices=["top", "bottom", "before", "after"]),
existing_rule=dict(),
commit=dict(type="bool", default=False),
audit_comment=dict(type="str"),
# TODO(gfreeman) - remove this in the next role release.
devicegroup=dict(),
),
Expand Down Expand Up @@ -481,6 +486,7 @@ def main():
location = module.params["location"]
existing_rule = module.params["existing_rule"]
commit = module.params["commit"]
audit_comment = module.params["audit_comment"]

# Retrieve the current rules.
try:
Expand All @@ -499,6 +505,10 @@ def main():
if module.params["state"] == "present":
changed |= helper.apply_position(new_rule, location, existing_rule, module)

# Add the audit comment, if applicable.
if changed and audit_comment and not module.check_mode:
new_rule.opstate.audit_comment.update(audit_comment)

# Optional commit.
if changed and commit:
helper.commit(module)
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/firewall/test_panos_security_rule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
application: ['ssh']
action: 'allow'
device_group: '{{ device_group | default(omit) }}'
audit_comment: 'Test audit comment'
register: result

- name: test_panos_security_rule - Assert create was successful
Expand All @@ -33,6 +34,7 @@
application: ['ssh']
action: 'allow'
device_group: '{{ device_group | default(omit) }}'
audit_comment: 'Testing audit_comment'
register: result

- name: test_panos_security_rule - Assert create (idempotence) was successful
Expand Down