Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SHELL := /bin/bash

PROTOS := protos/schema.proto protos/outputs.proto protos/version.proto
PROTO_URLS := https://raw.githubusercontent.com/falcosecurity/falco/master/userspace/falco/schema.proto https://raw.githubusercontent.com/falcosecurity/falco/master/userspace/falco/outputs.proto https://raw.githubusercontent.com/falcosecurity/falco/master/userspace/falco/version.proto
PROTO_SHAS := ad4e9d62717e82b9fb9ec30625d392fd66ced3e53eb73faea739c63063650ac3 18fa7f7a4870ae0e0703c775fda41362aa654445893546d9b2d49f59dd487026 c57a8a3f37a14ca8f33ce6d26156c9348e716029bca87bf9143807a68b1f31f5
PROTO_SHAS := c2dc18811ca0d2d2cece539bdee02a3f79239ca8fa0c0aa279a56277605084b7 8fdd0a921d87908df2731b8b8b40ac9a51d2369bad4351db4a3ad79584deaa61 c57a8a3f37a14ca8f33ce6d26156c9348e716029bca87bf9143807a68b1f31f5

PROTO_DIRS := $(dir ${PROTOS})
PROTO_DIRS_INCLUDES := $(patsubst %/, -I %, ${PROTO_DIRS})
Expand Down Expand Up @@ -40,9 +40,9 @@ clean: ${PROTO_DIRS}
@rm -rf $^

lint:
flake8
isort -rc .
isort .
black .
flake8

test:
python -m tests.mock &
Expand Down
2 changes: 1 addition & 1 deletion falco/__version__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__title__ = "falco"
__description__ = "Python client and SDK for Falco."
__url__ = "https://github.com/falcosecurity/client-py"
__version__ = "0.4.0"
__version__ = "0.5.0"
__author__ = "The Falco Authors"
__author_email__ = "cncf-falco-dev@lists.cncf.io"
__license__ = "Apache 2.0"
Expand Down
5 changes: 4 additions & 1 deletion falco/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
class Client:
def __init__(self, endpoint, client_crt=None, client_key=None, ca_root=None, output_format=None, *args, **kw):
if endpoint.startswith("unix:///"):
channel = grpc.insecure_channel(endpoint, options=[("grpc.max_receive_message_length", 1024 * 1024 * 512)],)
channel = grpc.insecure_channel(
endpoint,
options=[("grpc.max_receive_message_length", 1024 * 1024 * 512)],
)

else:
if None in [client_crt, client_key, ca_root]:
Expand Down
4 changes: 3 additions & 1 deletion falco/client_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ def get_grpc_channel_credentials(client_crt, client_key, ca_root):
certificate_chain = load_file(client_crt)

return grpc.ssl_channel_credentials(
root_certificates=root_certificates, private_key=private_key, certificate_chain=certificate_chain,
root_certificates=root_certificates,
private_key=private_key,
certificate_chain=certificate_chain,
)
33 changes: 6 additions & 27 deletions falco/domain/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from falco.domain.common import pb_timestamp_from_datetime
from falco.schema.outputs_pb2 import request, response
from falco.schema.schema_pb2 import priority, source
from falco.schema.schema_pb2 import priority


class OutputsRequest:
Expand Down Expand Up @@ -38,7 +38,7 @@ class OutputsResponse:
__slots__ = (
"time",
"_priority",
"_source",
"source",
"rule",
"output",
"output_fields",
Expand Down Expand Up @@ -67,17 +67,6 @@ class Priority(Enum):
7: Priority.DEBUG,
}

class Source(Enum):
SYSCALL = "syscall"
K8S_AUDIT = "k8s_audit"
INTERNAL = "internal"

PB_SOURCE_TO_SOURCE_MAP = {
0: Source.SYSCALL,
1: Source.K8S_AUDIT,
2: Source.INTERNAL,
}

SERIALIZERS = {"json": "to_json"}

def __init__(
Expand All @@ -93,7 +82,7 @@ def __init__(
):
self.time: datetime = time.astimezone(tz.tzutc())
self.priority: OutputsResponse.Priority = priority
self.source: OutputsResponse.Source = source
self.source: str = source
self.rule: str = rule
self.output: str = output
self.output_fields: Dict = output_fields
Expand All @@ -113,24 +102,14 @@ def priority(self, p):
if p and isinstance(p, OutputsResponse.Priority):
self._priority = p

@property
def source(self):
return self._source

@source.setter
def source(self, s):
self._source = None
if s and isinstance(s, OutputsResponse.Source):
self._source = s

@classmethod
def from_proto(cls, pb_response):
timestamp_dt = datetime.fromtimestamp(pb_response.time.seconds + pb_response.time.nanos / 1e9)

return cls(
time=timestamp_dt,
priority=OutputsResponse.PB_PRIORITY_TO_PRIORITY_MAP[pb_response.priority],
source=OutputsResponse.PB_SOURCE_TO_SOURCE_MAP[pb_response.source],
source=pb_response.source,
rule=pb_response.rule,
output=pb_response.output,
output_fields=dict(pb_response.output_fields),
Expand All @@ -142,7 +121,7 @@ def to_proto(self):
return response(
time=pb_timestamp_from_datetime(self.time),
priority=priority.Value(self.priority.value),
source=source.Value(self.source.value),
source=self.source,
rule=self.rule,
output=self.output,
output_fields=self.output_fields,
Expand All @@ -155,7 +134,7 @@ def to_json(self):
{
"time": self.time.isoformat(),
"priority": self.priority.value,
"source": self.source.value,
"source": self.source,
"rule": self.rule,
"output": self.output,
"output_fields": self.output_fields,
Expand Down
67 changes: 40 additions & 27 deletions falco/schema/outputs_pb2.py

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

Loading