11#! /bin/bash
22# verify_fips_deps.sh
33# Script to verify that the fips feature doesn't include ring and uses the proper crypto library
4- # Usage: ./verify_fips_deps.sh [package_name] (defaults to ddcommon if not specified)
4+ # Usage: ./verify_fips_deps.sh [package_name] [additional_features]
5+ # Examples:
6+ # ./verify_fips_deps.sh # Checks ddcommon with fips feature
7+ # ./verify_fips_deps.sh datadog-trace-utils # Checks trace-utils with fips feature
8+ # ./verify_fips_deps.sh datadog-trace-utils compression # Checks trace-utils with fips,compression features
59
610set -e
711
812# Default to ddcommon if no package is specified
913PACKAGE=${1:- ddcommon}
14+ shift 2> /dev/null || true
1015
11- echo " Checking ${PACKAGE} with fips feature..."
16+ # Additional features to include
17+ ADDITIONAL_FEATURES=" $@ "
18+ FEATURES=" fips"
1219
13- # Check if aws-lc-fips-sys is included with FIPS feature
14- FIPS_SYS_COUNT=$( cargo tree -p ${PACKAGE} --features fips | grep -c " aws-lc-fips-sys" || true)
20+ # Add additional features if specified
21+ if [ -n " $ADDITIONAL_FEATURES " ]; then
22+ FEATURES=" $FEATURES ,$ADDITIONAL_FEATURES "
23+ fi
24+
25+ echo " Checking ${PACKAGE} with features: ${FEATURES} ..."
26+
27+ # Check if aws-lc-fips-sys is included
28+ FIPS_SYS_COUNT=$( cargo tree -p ${PACKAGE} --features ${FEATURES} | grep -c " aws-lc-fips-sys" || true)
1529
1630if [ " $FIPS_SYS_COUNT " -eq 0 ]; then
1731 echo " ❌ ERROR: aws-lc-fips-sys is not included when fips feature is enabled"
1832 exit 1
1933else
20- echo " ✅ aws-lc-fips-sys is correctly included with fips feature "
34+ echo " ✅ aws-lc-fips-sys is correctly included with features: ${FEATURES} "
2135fi
2236
23- # Check if ring is included with FIPS feature (should not be)
24- RING_COUNT=$( cargo tree -p ${PACKAGE} --features fips | grep -c " ring" || true)
37+ # Check if ring is included (should not be for runtime dependencies )
38+ RING_COUNT=$( cargo tree -p ${PACKAGE} --features ${FEATURES} -e=no-dev -i ring | grep -c " ring" || true)
2539
2640if [ " $RING_COUNT " -eq 0 ]; then
27- echo " ✅ ring is correctly NOT included with fips feature "
41+ echo " ✅ ring is correctly NOT included with features: ${FEATURES} (in runtime dependencies) "
2842else
29- echo " ❌ ERROR: ring is included when fips feature is enabled"
43+ echo " ❌ ERROR: ring is included with features: ${FEATURES} (in runtime dependencies)"
44+ cargo tree -p ${PACKAGE} --features ${FEATURES} --no-dev-dependencies -i ring
3045 exit 1
3146fi
3247
33- echo " All checks passed! ${PACKAGE} FIPS feature doesn't include ring."
34- exit 0
48+ echo " All checks passed! ${PACKAGE} with features ${FEATURES} doesn't include ring in runtime dependencies ."
49+ exit 0
0 commit comments