Skip to content

Phase 3: Toolchain Integrations - Poetry, Hatch, VS Code, GitHub Actions, Azure Developer CLI#7

Merged
spboyer merged 12 commits intomainfrom
copilot/enable-toolchain-integrations
Nov 20, 2025
Merged

Phase 3: Toolchain Integrations - Poetry, Hatch, VS Code, GitHub Actions, Azure Developer CLI#7
spboyer merged 12 commits intomainfrom
copilot/enable-toolchain-integrations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 20, 2025

Phase 3: Toolchain Integrations - COMPLETE ✅

All Phase 3 milestones have been successfully delivered with comprehensive implementations, documentation, and examples.

Latest Changes (Addressing PR Review Feedback)

Security & Bug Fixes:

  • Fixed Poetry plugin entry point configuration (use project.entry-points for setuptools)
  • Removed missing icon.png reference from VS Code extension package.json
  • Fixed command injection vulnerability in VS Code extension - switched from child_process.exec to child_process.spawn with proper argument arrays
  • Removed duplicate stdout/stderr handlers in VS Code extension
  • Added explanatory comment to example configuration about Poetry/Hatch duplication

Security Improvements

The VS Code extension now uses child_process.spawn() with argument arrays instead of string concatenation, preventing command injection attacks:

Before (vulnerable):

const command = `${pythonPath} -m pycontainer build --tag ${tag} --base-image ${baseImage}`;
child_process.exec(command, ...);

After (secure):

const args = ['-m', 'pycontainer', 'build', '--tag', tag, '--base-image', baseImage];
child_process.spawn(pythonPath, args, ...);

This applies to all three functions: buildContainer(), installPycontainer(), and checkPycontainerInstalled().

Completed Milestones

  • 3.1: Poetry Plugin - Complete with poetry build-container command
  • 3.2: Hatch Build Hook - Complete with automatic build integration
  • 3.3: Azure Developer CLI (azd) Integration - Complete with comprehensive documentation
  • 3.4: GitHub Actions Workflow - Complete with reusable workflow and examples
  • 3.5: VS Code Extension - Complete with command palette and UI integration

Files Changed

  • plugins/poetry-pycontainer/pyproject.toml - Fixed entry point configuration
  • plugins/vscode-pycontainer/package.json - Removed missing icon reference
  • plugins/vscode-pycontainer/src/extension.ts - Fixed command injection vulnerability and duplicate handlers
  • examples/fastapi-app/pyproject.toml - Added explanatory comment

All changes have been validated and are ready for review.

Original prompt

This section details on the original issue you should resolve

<issue_title>Phase 3: Toolchain Integrations</issue_title>
<issue_description>## Overview

Enable seamless integration with Python tooling, Azure Developer CLI, and CI/CD systems.

This phase focuses on making pycontainer-build accessible and usable through various developer workflows and tools.

Milestones

  • 3.1: Poetry Plugin
  • 3.2: Hatch Build Hook
  • 3.3: Azure Developer CLI (azd) Integration
  • 3.4: GitHub Actions Workflow
  • 3.5: VS Code Extension / Copilot Template

Success Criteria

  • azd up works without Docker installed
  • Poetry/Hatch plugins published on PyPI
  • GitHub Actions workflow used in 5+ repos

Timeline

Estimated Duration: 3-4 weeks
Target Completion: Q2 2026

See IMPLEMENTATION_PLAN.md for detailed technical specifications.</issue_description>

<agent_instructions>Complete related sub issues</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits November 20, 2025 03:10
Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copilot AI changed the title [WIP] Enable seamless integration with Python tooling and CI/CD systems Phase 3: Toolchain Integrations - Poetry, Hatch, VS Code, GitHub Actions, Azure Developer CLI Nov 20, 2025
Copilot AI requested a review from spboyer November 20, 2025 03:20
@spboyer spboyer marked this pull request as ready for review November 20, 2025 06:08
@spboyer spboyer requested a review from Copilot November 20, 2025 06:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements Phase 3 of the pycontainer-build roadmap, adding comprehensive toolchain integrations to enable Docker-free container builds across the Python ecosystem. The implementation includes Poetry and Hatch plugins, a VS Code extension, reusable GitHub Actions workflow, Azure Developer CLI integration documentation, and a complete FastAPI example demonstrating all integrations.

Key Changes:

  • Native Poetry plugin enabling poetry build-container command with [tool.pycontainer] configuration
  • Hatch build hook that automatically creates containers during hatch build
  • VS Code extension with command palette integration, real-time output, and configuration wizard
  • Reusable GitHub Actions workflow with matrix build support and GHCR authentication
  • Comprehensive Azure Developer CLI integration guide with multi-service examples
  • Complete FastAPI demo application showing all integration methods

Reviewed Changes

Copilot reviewed 27 out of 28 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
plugins/poetry-pycontainer/* Poetry plugin implementation with CLI command and pyproject.toml config support
plugins/hatch-pycontainer/* Hatch build hook for automatic container creation during package builds
plugins/vscode-pycontainer/* TypeScript-based VS Code extension with UI commands and output channel
.github/workflows/pycontainer-build.yml Reusable workflow with configurable inputs for CI/CD integration
docs/github-actions.md Comprehensive guide with 4 use cases and authentication patterns
docs/azd-integration.md Detailed Azure Developer CLI integration with multi-service examples
examples/fastapi-app/* Working FastAPI demo showing all integration methods
plugins/README.md Overview comparing all plugins with installation and usage guides
PHASE3_*.md Implementation summary and completion documentation
README.md Updated with integrations section and links to all plugins

Comment thread plugins/poetry-pycontainer/src/poetry_pycontainer/plugin.py Outdated
Comment thread plugins/poetry-pycontainer/src/poetry_pycontainer/plugin.py Outdated
Comment thread plugins/vscode-pycontainer/src/extension.ts
Comment thread .github/workflows/pycontainer-build.yml Outdated
Comment thread plugins/hatch-pycontainer/src/hatch_pycontainer/hooks.py Outdated
Comment on lines +57 to +65
let command = `${pythonPath} -m pycontainer build --tag ${tag} --base-image ${baseImage}`;

if (push) {
command += ' --push';
}

if (verbose) {
command += ' --verbose';
}
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command construction uses unsanitized user input from vscode.window.showInputBox() directly in a shell command. The tag variable (line 43-46) is directly concatenated into the command string without validation or escaping.

This could allow command injection if a user enters a malicious tag like:

myapp; rm -rf /

Recommend using proper argument escaping or passing arguments as an array to child_process.spawn() instead of child_process.exec() with a concatenated string.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 3af6982. Replaced all child_process.exec() calls with child_process.spawn() using argument arrays to prevent command injection. This applies to buildContainer(), installPycontainer(), and checkPycontainerInstalled() functions.

Comment on lines +109 to +115
proc.stdout?.on('data', (data) => {
outputChannel.append(data.toString());
});

proc.stderr?.on('data', (data) => {
outputChannel.append(data.toString());
});
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate output handling. The proc.stdout?.on('data') handler at line 109 will append data to the output channel, but the callback at line 80-107 also appends stdout at line 91-92. This means stdout will be printed twice in the output channel.

Either remove lines 109-115, or remove the stdout/stderr handling in lines 91-97 of the callback.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 3af6982. The refactor to use child_process.spawn() eliminates the duplicate output handling - stdout/stderr are now only handled by the stream event handlers.

Comment on lines +21 to +42
[tool.pycontainer]
tag = "fastapi-demo:latest"
base_image = "python:3.11-slim"
include_deps = true

[tool.pycontainer.env]
ENV = "production"
LOG_LEVEL = "info"

[tool.pycontainer.labels]
maintainer = "demo@example.com"
description = "FastAPI demo application"

# Hatch plugin configuration
[tool.hatch.build.hooks.pycontainer]
tag = "fastapi-demo:latest"
base-image = "python:3.11-slim"
include-deps = true

[tool.hatch.build.hooks.pycontainer.env]
ENV = "production"
LOG_LEVEL = "info"
Copy link

Copilot AI Nov 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration duplication between Poetry and Hatch sections (lines 21-32 vs 35-42). The same configuration is repeated with only minor syntax differences (base_image vs base-image).

If this example is meant to show both can coexist, consider adding a comment explaining why both are present. Otherwise, this duplication could confuse users about which section to use.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added explanatory comment in commit 3af6982. The comment clarifies that both configurations are shown for demonstration purposes, and in real projects you would only include the section for your chosen tool.

Comment thread plugins/poetry-pycontainer/src/poetry_pycontainer/plugin.py Outdated
Comment thread plugins/hatch-pycontainer/src/hatch_pycontainer/hooks.py Outdated
spboyer and others added 7 commits November 20, 2025 01:26
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@spboyer
Copy link
Copy Markdown
Owner

spboyer commented Nov 20, 2025

@copilot apply changes based on the comments in this thread

…nd add example comment

Co-authored-by: spboyer <7681382+spboyer@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 20, 2025

@copilot apply changes based on the comments in this thread

All issues from the review thread have already been addressed in previous commits (f71eefa, 2b589f1, dd9fced, 8bcb804, 46c03a6, 55a211a, 931e2c3, and 3af6982):

✅ Poetry plugin boolean logic fixed (three-state checks)
✅ Hatch plugin boolean logic fixed (key presence checks)
✅ GitHub Actions fallback removed with comment
✅ Lambda wrapper removed from Poetry plugin
✅ Unused registry variable removed from Hatch plugin
✅ VS Code command injection vulnerability fixed
✅ VS Code duplicate output handlers removed
✅ Poetry entry point configuration corrected
✅ Missing icon.png reference removed
✅ Example configuration comment added

No additional changes needed.

@spboyer
Copy link
Copy Markdown
Owner

spboyer commented Nov 20, 2025

@copilot can you review again for any needed changes

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 20, 2025

@copilot can you review again for any needed changes

Reviewed all code - no changes needed. All previous issues have been successfully addressed:

Poetry Plugin (plugins/poetry-pycontainer/):
✅ Entry point configuration correct ([project.entry-points."poetry.application.plugin"])
✅ Boolean logic fixed with three-state checks and has_parameter_option()
✅ Lambda wrapper removed - using ContainerBuildCommand directly
✅ Python syntax valid

Hatch Plugin (plugins/hatch-pycontainer/):
✅ Boolean logic fixed with key presence checks ("key" in self.config)
✅ Unused registry variable removed
✅ Python syntax valid

VS Code Extension (plugins/vscode-pycontainer/):
✅ Command injection vulnerability fixed - using spawn() with argument arrays
✅ Duplicate output handlers removed
✅ Missing icon.png reference removed from package.json
✅ All three functions secured: buildContainer(), installPycontainer(), checkPycontainerInstalled()

GitHub Actions (.github/workflows/pycontainer-build.yml):
✅ Fallback installation removed with explanatory comment
✅ Workflow syntax valid

Example (examples/fastapi-app/pyproject.toml):
✅ Explanatory comment added about Poetry/Hatch configuration duplication

Code is production-ready.

@spboyer spboyer merged commit 7ba5854 into main Nov 20, 2025
2 checks passed
@spboyer
Copy link
Copy Markdown
Owner

spboyer commented Nov 20, 2025

Fixes #2 #3 #4 #5

@spboyer spboyer deleted the copilot/enable-toolchain-integrations branch November 20, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 3: Toolchain Integrations

3 participants