-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separating Out Access Logging (#1695)
### Feature or Bugfix <!-- please choose --> - Refactoring ### Detail - Move access logging to a separate environment logging bucket (rather than env default bucket used for athena queries and profiling job artifacts) ### Relates - <URL or Ticket> ### Security Please answer the questions below briefly where applicable, or write `N/A`. Based on [OWASP 10](https://owasp.org/Top10/en/). - Does this PR introduce or modify any input fields or queries - this includes fetching data from storage outside the application (e.g. a database, an S3 bucket)? - Is the input sanitized? - What precautions are you taking before deserializing the data you consume? - Is injection prevented by parametrizing queries? - Have you ensured no `eval` or similar functions are used? - Does this PR introduce any functionality or component that requires authorization? - How have you ensured it respects the existing AuthN/AuthZ mechanisms? - Are you logging failed auth attempts? - Are you using or adding any cryptographic features? - Do you use a standard proven implementations? - Are the used keys controlled by the customer? Where are they stored? - Are you introducing any new policies/roles/users? - Have you used the least-privilege principle? How? By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
d9f90df
commit b30a354
Showing
15 changed files
with
172 additions
and
68 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
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
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
55 changes: 55 additions & 0 deletions
55
backend/migrations/versions/49c6b18ed814_add_env_logs_bucket.py
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,55 @@ | ||
"""add_env_logs_bucket | ||
Revision ID: 49c6b18ed814 | ||
Revises: b21f86882012 | ||
Create Date: 2024-11-13 19:16:18.030415 | ||
""" | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
from sqlalchemy import orm, Column, String | ||
from sqlalchemy.ext.declarative import declarative_base | ||
|
||
from dataall.base.db import Resource, utils | ||
from dataall.base.utils.naming_convention import ( | ||
NamingConventionService, | ||
NamingConventionPattern, | ||
) | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = '49c6b18ed814' | ||
down_revision = 'b21f86882012' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
Base = declarative_base() | ||
|
||
|
||
class Environment(Resource, Base): | ||
__tablename__ = 'environment' | ||
environmentUri = Column(String, primary_key=True, default=utils.uuid('environment')) | ||
resourcePrefix = Column(String, nullable=False, default='dataall') | ||
EnvironmentLogsBucketName = Column(String, nullable=True) | ||
|
||
|
||
def upgrade(): | ||
op.add_column('environment', sa.Column('EnvironmentLogsBucketName', sa.String(), nullable=True)) | ||
bind = op.get_bind() | ||
session = orm.Session(bind=bind) | ||
environments = session.query(Environment).all() | ||
for env in environments: | ||
env.EnvironmentLogsBucketName = NamingConventionService( | ||
target_uri=env.environmentUri, | ||
target_label='env-access-logs', | ||
pattern=NamingConventionPattern.S3, | ||
resource_prefix=env.resourcePrefix, | ||
).build_compliant_name() | ||
session.commit() | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('environment', 'EnvironmentLogsBucketName') | ||
# ### end Alembic commands ### |
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
Oops, something went wrong.