Skip to content

Conversation

@shivasurya
Copy link
Owner

@shivasurya shivasurya commented Dec 9, 2025

Summary

Implements specialized converter functions for all 18 Dockerfile instruction types with comprehensive test coverage.

Stacked on: docker/02-tree-sitter-integration (#417)

Changes

  • Implement converters for all 18 instructions (FROM, RUN, CMD, COPY, ADD, ENV, ARG, USER, EXPOSE, WORKDIR, VOLUME, SHELL, HEALTHCHECK, LABEL, ENTRYPOINT, ONBUILD, STOPSIGNAL, MAINTAINER)
  • Add helper functions: extractParams, extractPaths, extractJSONArray
  • Update parser.go to dispatch to specialized converters
  • Comprehensive test suite with 100% coverage
  • Raw text parsing for robust tree-sitter variation handling

Checklist

  • Tests passing (gradle testGo)
  • Lint passing (gradle lintGo)

@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 93.90244% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.10%. Comparing base (aecb91a) to head (02ddb67).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sast-engine/graph/docker/converters.go 92.75% 9 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #418      +/-   ##
==========================================
+ Coverage   80.70%   81.10%   +0.39%     
==========================================
  Files          80       81       +1     
  Lines        7931     8172     +241     
==========================================
+ Hits         6401     6628     +227     
- Misses       1278     1287       +9     
- Partials      252      257       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@shivasurya shivasurya marked this pull request as ready for review December 9, 2025 03:03
@safedep
Copy link

safedep bot commented Dec 9, 2025

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

This report is generated by SafeDep Github App

shivasurya added a commit that referenced this pull request Dec 9, 2025
Implements comprehensive docker-compose.yml parsing support:

**YAML Parser Infrastructure:**
- YAMLGraph and YAMLNode structures for generic YAML parsing
- Support for scalar, mapping, and sequence node types
- ParseYAML() and ParseYAMLString() entry points
- Helper methods: Query(), HasChild(), GetChild(), ListValues(), StringValue()

**ComposeGraph Wrapper:**
- Service, volume, and network indexing for fast lookups
- Version detection and metadata tracking
- Thin wrapper over YAMLGraph with compose-specific methods

**Security Query Methods:**
- GetPrivilegedServices() - Detects privileged: true containers
- ServicesWithDockerSocket() - Finds Docker socket mounts (/var/run/docker.sock)
- ServiceHasSecurityOpt() - Checks security_opt values (e.g., seccomp:unconfined)
- ServiceHasCapability() - Validates cap_add/cap_drop settings
- ServicesWithHostNetwork() - Identifies network_mode: host usage
- ServicesWithoutReadOnly() - Finds writable containers
- ServiceExposesPort() - Port mapping validation
- ServiceHasEnvVar() - Environment variable checks (array and map formats)

**Test Coverage:**
- 20 comprehensive test cases covering all query methods
- Edge case handling (empty compose, missing sections, both env formats)
- 100% coverage on all new code

Files added:
- sast-engine/graph/parser_yaml.go (YAML infrastructure)
- sast-engine/graph/parser_compose.go (ComposeGraph wrapper)
- sast-engine/graph/parser_compose_test.go (comprehensive tests)

Part of: Dockerfile & Docker Compose Support
Stacked on: docker/03-instruction-converters (#418)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Copy link
Owner Author

shivasurya commented Dec 10, 2025

Merge activity

  • Dec 10, 6:17 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 10, 6:20 AM UTC: Graphite rebased this pull request as part of a merge.
  • Dec 10, 6:21 AM UTC: @shivasurya merged this pull request with Graphite.

@shivasurya shivasurya changed the base branch from docker/02-tree-sitter-integration to graphite-base/418 December 10, 2025 06:18
@shivasurya shivasurya changed the base branch from graphite-base/418 to main December 10, 2025 06:19
…kerfile instructions

Implement specialized converter functions for all Dockerfile instruction types:
- FROM: Extract image, tag, digest, and stage alias
- RUN/CMD/ENTRYPOINT: Parse shell and exec forms
- COPY/ADD: Extract source paths, destination, and flags (--from, --chown)
- ENV/ARG: Parse environment variables and build arguments
- USER: Parse user:group format
- EXPOSE: Extract ports and protocols
- WORKDIR: Track working directory and path type
- VOLUME/SHELL: Parse JSON arrays and paths
- HEALTHCHECK: Extract all health check options and command
- LABEL: Parse key-value label pairs
- ONBUILD/STOPSIGNAL/MAINTAINER: Extract instruction details

Key implementation details:
- Raw text parsing for robust handling of tree-sitter variations
- Helper functions for parameter/path/JSON array extraction
- 100% test coverage with comprehensive test suite
- All converters now return void instead of error

Part of PR #3: Instruction Converters
Stacked on: docker/02-tree-sitter-integration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
@shivasurya shivasurya force-pushed the docker/03-instruction-converters branch from 984c166 to 02ddb67 Compare December 10, 2025 06:20
@shivasurya shivasurya merged commit 280acea into main Dec 10, 2025
3 checks passed
@shivasurya shivasurya deleted the docker/03-instruction-converters branch December 10, 2025 06:21
shivasurya added a commit that referenced this pull request Dec 10, 2025
Implements comprehensive docker-compose.yml parsing support:

**YAML Parser Infrastructure:**
- YAMLGraph and YAMLNode structures for generic YAML parsing
- Support for scalar, mapping, and sequence node types
- ParseYAML() and ParseYAMLString() entry points
- Helper methods: Query(), HasChild(), GetChild(), ListValues(), StringValue()

**ComposeGraph Wrapper:**
- Service, volume, and network indexing for fast lookups
- Version detection and metadata tracking
- Thin wrapper over YAMLGraph with compose-specific methods

**Security Query Methods:**
- GetPrivilegedServices() - Detects privileged: true containers
- ServicesWithDockerSocket() - Finds Docker socket mounts (/var/run/docker.sock)
- ServiceHasSecurityOpt() - Checks security_opt values (e.g., seccomp:unconfined)
- ServiceHasCapability() - Validates cap_add/cap_drop settings
- ServicesWithHostNetwork() - Identifies network_mode: host usage
- ServicesWithoutReadOnly() - Finds writable containers
- ServiceExposesPort() - Port mapping validation
- ServiceHasEnvVar() - Environment variable checks (array and map formats)

**Test Coverage:**
- 20 comprehensive test cases covering all query methods
- Edge case handling (empty compose, missing sections, both env formats)
- 100% coverage on all new code

Files added:
- sast-engine/graph/parser_yaml.go (YAML infrastructure)
- sast-engine/graph/parser_compose.go (ComposeGraph wrapper)
- sast-engine/graph/parser_compose_test.go (comprehensive tests)

Part of: Dockerfile & Docker Compose Support
Stacked on: docker/03-instruction-converters (#418)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
shivasurya added a commit that referenced this pull request Dec 10, 2025
## Summary
Adds docker-compose.yml parsing support with security-focused query methods for detecting misconfigurations.

**Stacked on:** docker/03-instruction-converters (#418)

## Changes
- YAML parser infrastructure (YAMLGraph, YAMLNode)
- ComposeGraph wrapper with service/volume/network indexing
- Security query methods: GetPrivilegedServices, ServicesWithDockerSocket, ServiceHasSecurityOpt, ServiceHasCapability, etc.
- 20 comprehensive test cases with 100% coverage
- Support for both array and map environment variable formats

## Checklist
- [x] Tests passing (`gradle testGo`)
- [x] Lint passing (`gradle lintGo`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants