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

2.6.2 Security features #1737

Merged
merged 45 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
7053fdb
Updating overly permissive policies tagged by checkov for environment…
mourya-33 Nov 12, 2024
c26963c
Update sanitization technique (#1692)
noah-paige Nov 12, 2024
5939060
Fix/input validation (#1693)
noah-paige Nov 13, 2024
53a1205
Move worksheet logic to service layer (#1696)
dlpzx Nov 14, 2024
692d223
**WITH FIXES** Separating Out Access Logging (#1695)
noah-paige Nov 14, 2024
6206d98
return EnvironmentLogsBucketName from integraiton test getEnv query (…
noah-paige Nov 15, 2024
375f441
add explicit token duration config for both JWTs (#1698)
noah-paige Nov 15, 2024
d766bd4
**INSERTED** migrate local server to FastAPI (#1577)
petrkalos Sep 26, 2024
6913fe3
update fastapi dependency (#1699)
noah-paige Nov 15, 2024
75d0fd1
**WITH FIXES** Upgrade "cross-spawn" to "7.0.5" (#1701)
dlpzx Nov 18, 2024
aedaa29
Add MANAGE_SHARES permissions (#1702)
dlpzx Nov 19, 2024
5c71242
Disable introspection on prod sizing (#1704)
noah-paige Nov 20, 2024
4933f1d
Add snyk workflow on schedule (#1705)
noah-paige Nov 20, 2024
a4cfc6c
Bump python runtime to bump cdk klayers cryptography version (#1707)
noah-paige Nov 20, 2024
b117eb8
tenant-permission tests (#1694)
dlpzx Nov 20, 2024
01c63a4
Fix Snyk Workflow to Find Project Deps (#1708)
noah-paige Nov 21, 2024
ebb91ff
Added permission check - is tenant to update SSM parameters API (#1714)
dlpzx Nov 25, 2024
7f0dab7
Add GET_SHARE_OBJECT permissions to get data filters API (#1717)
dlpzx Nov 25, 2024
1265669
**WITH FIXES** Add permissions on list datasets for env group + cosme…
dlpzx Nov 25, 2024
385cd0d
Add GET_WORKSHEET permission in RUN_SQL_QUERY (#1716)
dlpzx Nov 25, 2024
6382d91
Unify Logger Config for Tasks (#1709)
noah-paige Nov 26, 2024
fce3455
Change Snyk Actions (#1713)
noah-paige Nov 26, 2024
095c208
Added permissions to Quicksight monitoring service layer (#1715)
dlpzx Nov 26, 2024
d318a7b
Add LIST_ENVIRONMENT_DATASETS permission for listing shared datasets …
dlpzx Nov 28, 2024
9d95e37
Add omics create_run unauthorized test and improve other tests (#1723)
dlpzx Nov 28, 2024
6df8588
Introduce is_owner permissions to Glossary mutations + add new integr…
dlpzx Nov 29, 2024
222c15c
Refactor env permissions + modify getTrustAccount (#1712)
dlpzx Dec 3, 2024
5c2b167
Avoid infinite loop in glossaries checks (#1725)
dlpzx Dec 3, 2024
ab1f6e5
Feed consistent permissions (#1722)
dlpzx Dec 4, 2024
ff9a8bd
Votes consistent permissions (#1724)
dlpzx Dec 4, 2024
283fadc
Consistent get_<DATA_ASSET> permissions - Dashboards (#1729)
dlpzx Dec 6, 2024
6ee449b
add resource permission checks (#1711)
petrkalos Dec 6, 2024
5d8e33a
Consistent get_<DATA_ASSET> permissions - S3_Datasets (#1727)
dlpzx Dec 10, 2024
f8597f6
Integrational Tests fixes (#1744)
SofiaSazonova Dec 19, 2024
e9bf72d
Bump deps and fix snyk workflow (#1745)
noah-paige Dec 19, 2024
938ca42
CICD Integration tests: new shares for pre-existing datasets (#1611)
SofiaSazonova Dec 23, 2024
1b195df
Feat/integ tests notifications (#1597)
noah-paige Dec 23, 2024
a692544
Fix global conftest shares after notifications PR (#1747)
noah-paige Dec 24, 2024
0e36462
Fix snyk (#1746)
noah-paige Dec 24, 2024
827bea8
Sync integration tests with main
dlpzx Dec 26, 2024
aeb9bc9
Upgrade werkzeug 3.0.3 -> 3.0.6
dlpzx Dec 26, 2024
b490962
Merge remote-tracking branch 'origin/v2.6.2' into security-prs-2.6.2
dlpzx Dec 27, 2024
03e20b6
Update requirements.txt
dlpzx Dec 27, 2024
b5545fa
Sync frontend packages with main
dlpzx Dec 27, 2024
33499b9
Remove write shares inputs from createShare API integration tests
dlpzx Jan 7, 2025
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
71 changes: 25 additions & 46 deletions .checkov.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
]
},
{
"file": "/cdk.out/asset.3045cb6b4340be1e173df6dcf6248d565aa849ceda3e2cf2c2f221ccee4bc1d6/pivotRole.yaml",
"file": "/cdk.out/asset.05d71d8b69cd4483d3c9db9120b556b718c72f349debbb79d461c74c4964b350/pivotRole.yaml",
"findings": [
{
"resource": "AWS::IAM::ManagedPolicy.PivotRolePolicy0",
Expand Down Expand Up @@ -490,12 +490,6 @@
{
"file": "/checkov_environment_synth.json",
"findings": [
{
"resource": "AWS::IAM::ManagedPolicy.dataallanothergroup111111servicespolicy19AC37181",
"check_ids": [
"CKV_AWS_111"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataallanothergroup111111servicespolicy2E85AF510",
"check_ids": [
Expand All @@ -508,24 +502,6 @@
"CKV_AWS_111"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataallanothergroup111111servicespolicy5A19E75CA",
"check_ids": [
"CKV_AWS_109"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataallanothergroup111111servicespolicyCC720210",
"check_ids": [
"CKV_AWS_109"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataalltestadmins111111servicespolicy1A0C96958",
"check_ids": [
"CKV_AWS_111"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataalltestadmins111111servicespolicy2B12D381A",
"check_ids": [
Expand All @@ -538,18 +514,6 @@
"CKV_AWS_111"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataalltestadmins111111servicespolicy3E3CBA9E",
"check_ids": [
"CKV_AWS_109"
]
},
{
"resource": "AWS::IAM::ManagedPolicy.dataalltestadmins111111servicespolicy56D7DC525",
"check_ids": [
"CKV_AWS_109"
]
},
{
"resource": "AWS::Lambda::Function.CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536",
"check_ids": [
Expand All @@ -563,38 +527,34 @@
"resource": "AWS::Lambda::Function.GlueDatabaseLFCustomResourceHandler7FAF0F82",
"check_ids": [
"CKV_AWS_115",
"CKV_AWS_117",
"CKV_AWS_173"
"CKV_AWS_117"
]
},
{
"resource": "AWS::Lambda::Function.LakeformationDefaultSettingsHandler2CBEDB06",
"check_ids": [
"CKV_AWS_115",
"CKV_AWS_117",
"CKV_AWS_173"
"CKV_AWS_117"
]
},
{
"resource": "AWS::Lambda::Function.dataallGlueDbCustomResourceProviderframeworkonEventF8347BA7",
"check_ids": [
"CKV_AWS_115",
"CKV_AWS_116",
"CKV_AWS_117",
"CKV_AWS_173"
"CKV_AWS_117"
]
},
{
"resource": "AWS::Lambda::Function.dataallLakeformationDefaultSettingsProviderframeworkonEventBB660E32",
"check_ids": [
"CKV_AWS_115",
"CKV_AWS_116",
"CKV_AWS_117",
"CKV_AWS_173"
"CKV_AWS_117"
]
},
{
"resource": "AWS::S3::Bucket.EnvironmentDefaultBucket78C3A8B0",
"resource": "AWS::S3::Bucket.EnvironmentDefaultLogBucket7F0EFAB3",
"check_ids": [
"CKV_AWS_18"
]
Expand Down Expand Up @@ -653,6 +613,25 @@
}
]
},
{
"file": "/checkov_pipeline_synth.json",
"findings": [
{
"resource": "AWS::IAM::Role.PipelineRoleDCFDBB91",
"check_ids": [
"CKV_AWS_107",
"CKV_AWS_108",
"CKV_AWS_111"
]
},
{
"resource": "AWS::S3::Bucket.thistableartifactsbucketDB1C8C64",
"check_ids": [
"CKV_AWS_18"
]
}
]
},
{
"file": "/frontend/docker/prod/Dockerfile",
"findings": [
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/snyk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Snyk

on:
workflow_dispatch:

schedule:
- cron: "0 9 * * 1" # runs each Monday at 9:00 UTC

permissions:
contents: read
security-events: write

jobs:
security:
strategy:
matrix:
python-version: [3.9]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install All Requirements
run: make install
- name: Run Snyk to check for vulnerabilities
run: snyk test --all-projects --detection-depth=5 --severity-threshold=high
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ venv:
@python3 -m venv "venv"
@/bin/bash -c "source venv/bin/activate"

install: upgrade-pip install-deploy install-backend install-cdkproxy install-tests
install: upgrade-pip install-deploy install-backend install-cdkproxy install-tests install-integration-tests install-custom-auth install-userguide

upgrade-pip:
pip install --upgrade pip setuptools
Expand All @@ -36,6 +36,12 @@ install-tests:
install-integration-tests:
pip install -r tests_new/integration_tests/requirements.txt

install-custom-auth:
pip install -r deploy/custom_resources/custom_authorizer/requirements.txt

install-userguide:
pip install -r documentation/userguide/requirements.txt

lint:
pip install ruff
ruff check --fix
Expand Down
10 changes: 9 additions & 1 deletion backend/api_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from dataall.base.db import get_engine
from dataall.base.loader import load_modules, ImportMode

from graphql.pyutils import did_you_mean

logger = logging.getLogger()
logger.setLevel(os.environ.get('LOG_LEVEL', 'INFO'))
Expand All @@ -32,6 +33,11 @@
for name in ['boto3', 's3transfer', 'botocore', 'boto']:
logging.getLogger(name).setLevel(logging.ERROR)

ALLOW_INTROSPECTION = True if os.getenv('ALLOW_INTROSPECTION') == 'True' else False

if not ALLOW_INTROSPECTION:
did_you_mean.__globals__['MAX_LENGTH'] = 0

load_modules(modes={ImportMode.API})
SCHEMA = bootstrap_schema()
TYPE_DEFS = gql(SCHEMA.gql(with_directives=False))
Expand Down Expand Up @@ -137,7 +143,9 @@ def handler(event, context):
else:
raise Exception(f'Could not initialize user context from event {event}')

success, response = graphql_sync(schema=executable_schema, data=query, context_value=app_context)
success, response = graphql_sync(
schema=executable_schema, data=query, context_value=app_context, introspection=ALLOW_INTROSPECTION
)

dispose_context()
response = json.dumps(response)
Expand Down
11 changes: 11 additions & 0 deletions backend/dataall/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
from . import core, version
from .base import utils, db, api
import logging
import os
import sys

logging.basicConfig(
level=os.environ.get('LOG_LEVEL', 'INFO'),
handlers=[logging.StreamHandler(sys.stdout)],
format='[%(levelname)s] %(message)s',
)
for name in ['boto3', 's3transfer', 'botocore', 'boto', 'urllib3']:
logging.getLogger(name).setLevel(logging.ERROR)
15 changes: 5 additions & 10 deletions backend/dataall/base/cdkproxy/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
aws-cdk-lib==2.99.0
boto3==1.28.23
boto3-stubs==1.28.23
botocore==1.31.23
aws-cdk-lib==2.160.0
boto3==1.35.26
boto3-stubs==1.35.26
cdk-nag==2.7.2
constructs==10.0.73
starlette==0.36.3
fastapi == 0.109.2
Flask==2.3.2
fastapi == 0.115.5
PyYAML==6.0
requests==2.32.2
tabulate==0.8.9
uvicorn==0.15.0
werkzeug==3.0.3
constructs>=10.0.0,<11.0.0
werkzeug==3.0.6
git-remote-codecommit==1.16
aws-ddk-core==1.3.0
2 changes: 1 addition & 1 deletion backend/dataall/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
that in the request scope

The class uses Flask's approach to handle request: ThreadLocal
That approach should work fine for AWS Lambdas and local server that uses Flask app
That approach should work fine for AWS Lambdas and local server that uses FastApi app
"""

from dataclasses import dataclass
Expand Down
3 changes: 3 additions & 0 deletions backend/dataall/base/feature_toggle_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Contains decorators that check if a feature has been enabled or not
"""

import functools

from dataall.base.config import config
from dataall.base.utils.decorator_utls import process_func

Expand All @@ -10,6 +12,7 @@ def is_feature_enabled(config_property: str):
def decorator(f):
fn, fn_decorator = process_func(f)

@functools.wraps(fn)
def decorated(*args, **kwargs):
value = config.get_property(config_property)
if not value:
Expand Down
34 changes: 28 additions & 6 deletions backend/dataall/base/utils/naming_convention.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,46 @@
from enum import Enum

import re
from .slugify import slugify


class NamingConventionPattern(Enum):
S3 = {'regex': '[^a-zA-Z0-9-]', 'separator': '-', 'max_length': 63}
S3 = {
'regex': '[^a-zA-Z0-9-]',
'separator': '-',
'max_length': 63,
'valid_external_regex': '(?!(^xn--|.+-s3alias$))^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$',
}
KMS = {'regex': '[^a-zA-Z0-9-]$', 'separator': '-', 'max_length': 63, 'valid_external_regex': '^[a-zA-Z0-9_-]+$'}
IAM = {'regex': '[^a-zA-Z0-9-_]', 'separator': '-', 'max_length': 63} # Role names up to 64 chars
IAM_POLICY = {'regex': '[^a-zA-Z0-9-_]', 'separator': '-', 'max_length': 128} # Policy names up to 128 chars
GLUE = {'regex': '[^a-zA-Z0-9_]', 'separator': '_', 'max_length': 240} # Limit 255 - 15 extra chars buffer
GLUE = {
'regex': '[^a-zA-Z0-9_]',
'separator': '_',
'max_length': 240,
'valid_external_regex': '^[a-zA-Z0-9_]+$',
} # Limit 255 - 15 extra chars buffer
GLUE_ETL = {'regex': '[^a-zA-Z0-9-]', 'separator': '-', 'max_length': 52}
NOTEBOOK = {'regex': '[^a-zA-Z0-9-]', 'separator': '-', 'max_length': 63}
MLSTUDIO_DOMAIN = {'regex': '[^a-zA-Z0-9-]', 'separator': '-', 'max_length': 63}
DEFAULT = {'regex': '[^a-zA-Z0-9-_]', 'separator': '-', 'max_length': 63}
DEFAULT_SEARCH = {'regex': '[^a-zA-Z0-9-_:. ]'}
OPENSEARCH = {'regex': '[^a-z0-9-]', 'separator': '-', 'max_length': 27}
OPENSEARCH_SERVERLESS = {'regex': '[^a-z0-9-]', 'separator': '-', 'max_length': 31}
DATA_FILTERS = {'regex': '[^a-z0-9_]', 'separator': '_', 'max_length': 31}
REDSHIFT_DATASHARE = {
'regex': '[^a-zA-Z0-9_]',
'separator': '_',
'max_length': 1000,
} # Maximum length of 2147483647


class NamingConventionService:
def __init__(
self,
target_label: str,
target_uri: str,
pattern: NamingConventionPattern,
resource_prefix: str,
target_uri: str = '',
resource_prefix: str = '',
):
self.target_label = target_label
self.target_uri = target_uri if target_uri else ''
Expand All @@ -37,4 +55,8 @@ def build_compliant_name(self) -> str:
separator = NamingConventionPattern[self.service].value['separator']
max_length = NamingConventionPattern[self.service].value['max_length']
suffix = f'-{self.target_uri}' if len(self.target_uri) else ''
return f"{slugify(self.resource_prefix + '-' + self.target_label[:(max_length- len(self.resource_prefix + self.target_uri))] + suffix, regex_pattern=fr'{regex}', separator=separator, lowercase=True)}"
return f"{slugify(self.resource_prefix + '-' + self.target_label[:(max_length - len(self.resource_prefix + self.target_uri))] + suffix, regex_pattern=fr'{regex}', separator=separator, lowercase=True)}"

def sanitize(self):
regex = NamingConventionPattern[self.service].value['regex']
return re.sub(regex, '', self.target_label)
1 change: 1 addition & 0 deletions backend/dataall/core/environment/api/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

getTrustAccount = gql.QueryField(
name='getTrustAccount',
args=[gql.Argument(name='organizationUri', type=gql.NonNullableType(gql.String))],
type=gql.String,
resolver=get_trust_account,
test_scope='Environment',
Expand Down
Loading