Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ Usually all custom actions should be listed in the mapping because otherwise the

The mapping of actions is complex: For payload-encoded actions a default-mapping will be applied which determines the primary action (e.g. `update`) from the HTTP method and adds the action name from the payload (e.g. `update/myaction`).

For path-encoded actions you can reach a similar behaviour with a generic rule of the form `"<method>:*": "<action>"` (e.g. `"POST:*": "read"`). You can refer to the actual action name in the path via `*` (e.g. `"POST:*": "update/*"`). If the right side of the rule is `null, the `entire request will be suppressed, so that no event is emitted (e.g. `"POST:*": null`).
For path-encoded actions you can reach a similar behaviour with a generic rule of the form `"<method>:*": "<action>"` (e.g. `"POST:*": "read"`). You can refer to the actual action name in the path via `*` (e.g. `"POST:*": "update/*"`). If the right side of the rule is `null`, the entire request will be suppressed, so that no event is emitted (e.g. `"POST:*": null`).

If there is no rule matching the path suffix, it will be interpreted as a _key_, not as an action. That means that the action will be determined from the HTTP method only and an attachment with the name `key` and the name of the key as `content` will be added to the event.

Expand Down Expand Up @@ -269,9 +269,9 @@ In our example this looks like this:
Undeclared Resources
--------------------

Resources that are not declared in the mapping file will be reported as _unknown_ in the operational logs. Still the middleware tries to create events for them based on heuristics. They can be recognized by the `X` prefix in the resource name.
Resources that are not declared in the mapping file will be reported as _unknown_ in the operational logs. Still the middleware tries to create events for them based on heuristics.

When those X-resources show up, the mapping file should be extended with an appropriate resource definition. The reason is that the heuristics to discover and map undeclared resources are not covering all kinds of requests. There are ambiguities.
When those unknown resoucre log messages show up, the mapping file should be extended with an appropriate resource definition. The reason is that the heuristics to discover and map undeclared resources are not covering all kinds of requests. There are ambiguities.

Developing Audit Middleware
===========================
Expand Down
1 change: 0 additions & 1 deletion auditmiddleware/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ def register_resource(self, parent_type_uri, token):
res_name = token.replace('_', '-')
if res_name.startswith('os-'):
res_name = res_name[3:]
res_name = 'X' + res_name
res_dict = {'api_name': token}
sub_res_spec, _ = self._build_res_spec(res_name,
parent_type_uri,
Expand Down
10 changes: 4 additions & 6 deletions auditmiddleware/tests/unit/test_audit_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,7 @@ def test_post_undefined_action_generic(self):
def test_post_resource_undeclared(self):
"""Test that resource paths w/o mapping are still causing events.

Those events can be spotted by the "X" prefixing the resource
name derived from the URL path.
Those events can be spotted by log messages in the api container.
"""
rid = str(uuid.uuid4().hex)
rname = "myname"
Expand All @@ -560,13 +559,12 @@ def test_post_resource_undeclared(self):
event = self.build_event(request, response)

self.check_event(request, response, event, taxonomy.ACTION_CREATE,
"compute/Xyetunknown", rid, rname)
"compute/yetunknown", rid, rname)

def test_put_resource_undeclared(self):
"""Test that resource paths w/o mapping are still causing events.

Those events can be spotted by the "X" prefixing the resource
name derived from the URL path.
Those events can be spotted by log messages in the api container.
"""
rid = str(uuid.uuid4().hex)
rid2 = str(uuid.uuid4().hex)
Expand All @@ -577,7 +575,7 @@ def test_put_resource_undeclared(self):
event = self.build_event(request, response)

self.check_event(request, response, event, taxonomy.ACTION_UPDATE,
"compute/Xyetunknown/Xuchild", rid2)
"compute/yetunknown/uchild", rid2)

def test_post_action_no_response(self):
"""Test events are created for POST actions with no response payload.
Expand Down