This repository has been archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
353- initial infra for fideslog integration (#541)
* 353- initial infra for fideslog integration * adds changelog * cr and adds storage of analytics id in config * implement internal mode, exclude tests/CI, implement sending server start event * remove validationerr * format * sort * lint * cr changes * lint fixes * Adds root_user to test toml config * Add analytics opt out arg to parser of run_infrastructure * implicit true when passing env var to docker-compose * small code style changes, and updating test fidesops.toml to opt out of analytics by default * missing comma * spacing issue * remove fidesctl dep
- Loading branch information
1 parent
bfe29b3
commit 8812b89
Showing
13 changed files
with
220 additions
and
56 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
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 |
---|---|---|
@@ -1,34 +1,37 @@ | ||
# Configuration TOML used in select unit tests | ||
PORT=8080 | ||
PORT = 8080 | ||
|
||
[database] | ||
SERVER="testserver" | ||
USER="testuser" | ||
PASSWORD="testpassword" | ||
DB="testdb" | ||
TEST_DB="test_testdb" | ||
ENABLED=true | ||
SERVER = "testserver" | ||
USER = "testuser" | ||
PASSWORD = "testpassword" | ||
DB = "testdb" | ||
TEST_DB = "test_testdb" | ||
ENABLED = true | ||
|
||
[redis] | ||
HOST="testredis" | ||
PASSWORD="testpassword" | ||
PORT=1234 | ||
CHARSET="utf8" | ||
DEFAULT_TTL_SECONDS=1000 | ||
DB_INDEX=0 | ||
ENABLED=true | ||
HOST = "testredis" | ||
PASSWORD = "testpassword" | ||
PORT = 1234 | ||
CHARSET = "utf8" | ||
DEFAULT_TTL_SECONDS = 1000 | ||
DB_INDEX = 0 | ||
ENABLED = true | ||
|
||
[security] | ||
APP_ENCRYPTION_KEY="atestencryptionkeythatisvalidlen" | ||
CORS_ORIGINS=["http://test.com", "https://test.com"] | ||
OAUTH_ROOT_CLIENT_ID="testrootclientid" | ||
OAUTH_ROOT_CLIENT_SECRET="testrootclientsecret" | ||
DRP_JWT_SECRET="testdrpsecret" | ||
APP_ENCRYPTION_KEY = "atestencryptionkeythatisvalidlen" | ||
CORS_ORIGINS = [ "http://test.com", "https://test.com",] | ||
OAUTH_ROOT_CLIENT_ID = "testrootclientid" | ||
OAUTH_ROOT_CLIENT_SECRET = "testrootclientsecret" | ||
DRP_JWT_SECRET = "testdrpsecret" | ||
LOG_LEVEL = "DEBUG" | ||
|
||
[execution] | ||
TASK_RETRY_COUNT=0 | ||
TASK_RETRY_DELAY=1 | ||
TASK_RETRY_BACKOFF=1 | ||
REQUIRE_MANUAL_REQUEST_APPROVAL=false | ||
MASKING_STRICT=true | ||
TASK_RETRY_COUNT = 0 | ||
TASK_RETRY_DELAY = 1 | ||
TASK_RETRY_BACKOFF = 1 | ||
REQUIRE_MANUAL_REQUEST_APPROVAL = false | ||
MASKING_STRICT = true | ||
|
||
[root_user] | ||
ANALYTICS_OPT_OUT = true | ||
ANALYTICS_ID = "internal" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
PORT=8080 | ||
|
||
[database] | ||
SERVER="db" | ||
USER="postgres" | ||
PASSWORD="216f4b49bea5da4f84f05288258471852c3e325cd336821097e1e65ff92b528a" | ||
DB="app" | ||
TEST_DB="test" | ||
ENABLED=true | ||
SERVER = "db" | ||
USER = "postgres" | ||
PASSWORD = "216f4b49bea5da4f84f05288258471852c3e325cd336821097e1e65ff92b528a" | ||
DB = "app" | ||
TEST_DB = "test" | ||
ENABLED = true | ||
|
||
[redis] | ||
HOST="redis" | ||
PASSWORD="testpassword" | ||
PORT=6379 | ||
CHARSET="utf8" | ||
DEFAULT_TTL_SECONDS=604800 | ||
DB_INDEX=0 | ||
ENABLED=true | ||
HOST = "redis" | ||
PASSWORD = "testpassword" | ||
PORT = 6379 | ||
CHARSET = "utf8" | ||
DEFAULT_TTL_SECONDS = 604800 | ||
DB_INDEX = 0 | ||
ENABLED = true | ||
|
||
[security] | ||
APP_ENCRYPTION_KEY="OLMkv91j8DHiDAULnK5Lxx3kSCov30b3" | ||
CORS_ORIGINS=["http://localhost", "http://localhost:8080", "http://localhost:3000", "http://localhost:3001"] | ||
ENCODING="UTF-8" | ||
OAUTH_ROOT_CLIENT_ID="fidesopsadmin" | ||
OAUTH_ROOT_CLIENT_SECRET="fidesopsadminsecret" | ||
DRP_JWT_SECRET="secret" | ||
APP_ENCRYPTION_KEY = "OLMkv91j8DHiDAULnK5Lxx3kSCov30b3" | ||
CORS_ORIGINS = [ "http://localhost", "http://localhost:8080", "http://localhost:3000", "http://localhost:3001",] | ||
ENCODING = "UTF-8" | ||
OAUTH_ROOT_CLIENT_ID = "fidesopsadmin" | ||
OAUTH_ROOT_CLIENT_SECRET = "fidesopsadminsecret" | ||
DRP_JWT_SECRET = "secret" | ||
LOG_LEVEL = "INFO" | ||
|
||
[execution] | ||
TASK_RETRY_COUNT=0 | ||
TASK_RETRY_DELAY=1 | ||
TASK_RETRY_BACKOFF=1 | ||
REQUIRE_MANUAL_REQUEST_APPROVAL=false | ||
MASKING_STRICT=true | ||
TASK_RETRY_COUNT = 0 | ||
TASK_RETRY_DELAY = 1 | ||
TASK_RETRY_BACKOFF = 1 | ||
REQUIRE_MANUAL_REQUEST_APPROVAL = false | ||
MASKING_STRICT = true | ||
|
||
[root_user] | ||
ANALYTICS_OPT_OUT = false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
import os | ||
from platform import system | ||
|
||
from fideslog.sdk.python.client import AnalyticsClient | ||
from fideslog.sdk.python.event import AnalyticsEvent | ||
from fideslog.sdk.python.exceptions import AnalyticsError | ||
|
||
from fidesops import __version__ as fidesops_version | ||
from fidesops.core.config import config | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def in_docker_container() -> bool: | ||
"""`True` if the command was submitted within a Docker container. Default: `False`.""" | ||
return bool(os.getenv("RUNNING_IN_DOCKER") == "true") | ||
|
||
|
||
def running_on_local_host() -> bool: | ||
"""For events submitted as a result of making API server requests, `True` if the API server is running on the user's local host. Default: `False`.""" | ||
return True | ||
|
||
|
||
analytics_client = AnalyticsClient( | ||
client_id=config.root_user.ANALYTICS_ID, | ||
developer_mode=config.dev_mode, | ||
extra_data=None, | ||
os=system(), | ||
product_name="fidesops", | ||
production_version=fidesops_version, | ||
) | ||
|
||
|
||
def send_analytics_event(event: AnalyticsEvent) -> None: | ||
if config.root_user.ANALYTICS_OPT_OUT: | ||
return | ||
try: | ||
analytics_client.send(event) | ||
except AnalyticsError as err: | ||
logger.warning(f"Error sending analytics event: {err}") | ||
else: | ||
logger.info( | ||
f"Analytics event sent: {event.event} with client id: {analytics_client.client_id}" | ||
) |
Oops, something went wrong.