-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add FIPS workflow file * Add Windows steps * Experiment with download from S3 for Windows * Revert to building openssl * Switch Windows steps to download from S3 * Remove unnecessary steps * Add FIPS_MODULE_VERSION for Linux * Finish handling Python in setup * Remove unnecessary steps * Add md5 tests * Make md5 tests pass * Try separating FIPS and non-FIPS md5 tests * Add e2e tests for TLS FIPS * Make TLS E2E tests pass * Switch from env vars to C bindings * Revert to using env vars * Add option for e2e env vars in workflow * Remove unnecessary comments from start-server.sh * Rework enable_fips for user env var overwrite * Disable FIPS tests by default in master * Add changelogs * Fix license headers * Remove unfinished tests * Remove openssl.cnf workaround * Remove unused compose file * Fix license headers * Bring back integration tests * Experiment with integration tests * Remove integration test files * Restore pr.yml and test-target.yml * Move FIPS workflow to test-fips.yml * Fix pytest "not fips" args * Update test-fips.yml * Fix unvalid workflow * Modify JOB_NAME env var * Re-introduce experimental integration tests * Merge e2e tests and clean test-fips workflow * Merge integration tests and use monkeypatch in setup fixture * Attemp to fix experimental workflow * Replace ddev with pytest in experimental workflow * Revert "Replace ddev with pytest in experimental workflow" This reverts commit fda181f. * Remove experimental tests from PR * Add unit tests for env var logic * Switch to using marks to exclude fips from test-target * Revert "Switch to using marks to exclude fips from test-target" This reverts commit 3e3e51a.
- Loading branch information
Showing
16 changed files
with
463 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
name: Test FIPS E2E | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
agent-image: | ||
description: "Agent image to use" | ||
required: false | ||
type: string | ||
target: | ||
description: "Target to test" | ||
required: false | ||
type: string | ||
pull_request: | ||
path: | ||
- datadog_checks_base/datadog_checks/** | ||
schedule: | ||
- cron: '0 0,8,16 * * *' | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
run: | ||
name: "Test FIPS" | ||
runs-on: ["ubuntu-22.04"] | ||
|
||
env: | ||
FORCE_COLOR: "1" | ||
PYTHON_VERSION: "3.12" | ||
DDEV_E2E_AGENT: "${{ inputs.agent-image || 'datadog/agent-dev:master-fips' }}" | ||
# Test results for later processing | ||
TEST_RESULTS_BASE_DIR: "test-results" | ||
# Tracing to monitor our test suite | ||
DD_ENV: "ci" | ||
DD_SERVICE: "ddev-integrations-core" | ||
DD_TAGS: "team:agent-integrations" | ||
DD_TRACE_ANALYTICS_ENABLED: "true" | ||
# Capture traces for a separate job to do the submission | ||
TRACE_CAPTURE_BASE_DIR: "trace-captures" | ||
TRACE_CAPTURE_LOG: "trace-captures/output.log" | ||
|
||
steps: | ||
|
||
- name: Set environment variables with sanitized paths | ||
run: | | ||
JOB_NAME="test-fips" | ||
echo "TEST_RESULTS_DIR=$TEST_RESULTS_BASE_DIR/$JOB_NAME" >> $GITHUB_ENV | ||
echo "TRACE_CAPTURE_FILE=$TRACE_CAPTURE_BASE_DIR/$JOB_NAME" >> $GITHUB_ENV | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "${{ env.PYTHON_VERSION }}" | ||
cache: 'pip' | ||
|
||
- name: Restore cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: '~/.cache/pip' | ||
key: >- | ||
${{ format( | ||
'v01-python-{0}-{1}-{2}-{3}', | ||
env.pythonLocation, | ||
hashFiles('datadog_checks_base/pyproject.toml'), | ||
hashFiles('datadog_checks_dev/pyproject.toml'), | ||
hashFiles('ddev/pyproject.toml') | ||
)}} | ||
restore-keys: |- | ||
v01-python-${{ env.pythonLocation }} | ||
- name: Install ddev from local folder | ||
run: |- | ||
pip install -e ./datadog_checks_dev[cli] | ||
pip install -e ./ddev | ||
- name: Configure ddev | ||
run: |- | ||
ddev config set repos.core . | ||
ddev config set repo core | ||
- name: Prepare for testing | ||
env: | ||
PYTHONUNBUFFERED: "1" | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }} | ||
ORACLE_DOCKER_USERNAME: ${{ secrets.ORACLE_DOCKER_USERNAME }} | ||
ORACLE_DOCKER_PASSWORD: ${{ secrets.ORACLE_DOCKER_PASSWORD }} | ||
SINGLESTORE_LICENSE: ${{ secrets.SINGLESTORE_LICENSE }} | ||
DD_GITHUB_USER: ${{ github.actor }} | ||
DD_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: ddev ci setup ${{ inputs.target || 'tls' }} | ||
|
||
- name: Set up trace capturing | ||
env: | ||
PYTHONUNBUFFERED: "1" | ||
run: |- | ||
mkdir "${{ env.TRACE_CAPTURE_BASE_DIR }}" | ||
python .ddev/ci/scripts/traces.py capture --port "8126" --record-file "${{ env.TRACE_CAPTURE_FILE }}" > "${{ env.TRACE_CAPTURE_LOG }}" 2>&1 & | ||
- name: Run E2E tests with FIPS disabled | ||
env: | ||
DD_API_KEY: "${{ secrets.DD_API_KEY }}" | ||
run: | | ||
ddev env test -e GOFIPS=0 --new-env --junit ${{ inputs.target || 'tls' }} -- all -m "fips_off" | ||
- name: Run E2E tests with FIPS enabled | ||
env: | ||
DD_API_KEY: "${{ secrets.DD_API_KEY }}" | ||
run: | | ||
ddev env test -e GOFIPS=1 --new-env --junit ${{ inputs.target || 'tls' }} -- all -k "fips_on" | ||
- name: View trace log | ||
if: always() | ||
run: cat "${{ env.TRACE_CAPTURE_LOG }}" | ||
|
||
- name: Upload captured traces | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "traces-${{ inputs.target || 'tls' }}" | ||
path: "${{ env.TRACE_CAPTURE_FILE }}" | ||
|
||
- name: Finalize test results | ||
if: always() | ||
run: |- | ||
mkdir -p "${{ env.TEST_RESULTS_DIR }}" | ||
if [[ -d ${{ inputs.target || 'tls' }}/.junit ]]; then | ||
mv ${{ inputs.target || 'tls' }}/.junit/*.xml "${{ env.TEST_RESULTS_DIR }}" | ||
fi | ||
- name: Upload test results | ||
if: always() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: "test-results-${{ inputs.target || 'tls' }}" | ||
path: "${{ env.TEST_RESULTS_BASE_DIR }}" | ||
|
||
- name: Upload coverage data | ||
if: > | ||
!github.event.repository.private && | ||
always() | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
files: "${{ inputs.target || 'tls' }}/coverage.xml" | ||
flags: "${{ inputs.target || 'tls' }}" |
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 @@ | ||
Add FIPS switch |
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,32 @@ | ||
# (C) Datadog, Inc. 2024-present | ||
# All rights reserved | ||
# Licensed under a 3-clause BSD style license (see LICENSE) | ||
|
||
import os | ||
|
||
|
||
def enable_fips(path_to_openssl_conf=None, path_to_openssl_modules=None): | ||
path_to_embedded = None | ||
if os.getenv("OPENSSL_CONF") is None: | ||
if path_to_openssl_conf is None: | ||
path_to_embedded = _get_embedded_path() if path_to_embedded is None else path_to_embedded | ||
path_to_openssl_conf = path_to_embedded / "ssl" / "openssl.cnf" | ||
if not path_to_openssl_conf.exists(): | ||
raise RuntimeError(f'The configuration file "{path_to_openssl_conf}" does not exist') | ||
os.environ["OPENSSL_CONF"] = str(path_to_openssl_conf) | ||
|
||
if os.getenv("OPENSSL_MODULES") is None: | ||
if path_to_openssl_modules is None: | ||
path_to_embedded = _get_embedded_path() if path_to_embedded is None else path_to_embedded | ||
path_to_openssl_modules = path_to_embedded / "lib" / "ossl-modules" | ||
if not path_to_openssl_conf.exists(): | ||
raise RuntimeError(f'The directory "{path_to_openssl_modules}" does not exist') | ||
os.environ["OPENSSL_MODULES"] = str(path_to_openssl_modules) | ||
|
||
|
||
def _get_embedded_path(): | ||
import sys | ||
from pathlib import Path | ||
|
||
embedded_dir = "embedded3" if os.name == 'nt' else "embedded" | ||
return Path(sys.executable.split("embedded")[0] + embedded_dir) |
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 @@ | ||
Add FIPS switch |
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.