Skip to content

Refactor prepare task to use typed inputs and outputs#1324

Draft
justin-thurman wants to merge 7 commits into
mainfrom
CAP-4391
Draft

Refactor prepare task to use typed inputs and outputs#1324
justin-thurman wants to merge 7 commits into
mainfrom
CAP-4391

Conversation

@justin-thurman

@justin-thurman justin-thurman commented May 8, 2026

Copy link
Copy Markdown
Contributor

Follows

#1302

Description

This PR continues the migration of CLI tasks to the new, typed structure established in #1302, migrating the prepare task. Like the initialize task refactored in #1323, this task has distinct subtasks, which I've split up into separate files to aid readability. So the commits in this PR are structured around migrating each of these subtasks separately, alongside some generic housecleaning. The main prepare/index.ts orchestration layer is updated throughout the other commits (I couldn't find a clean way to put this in its own commit, unfortunately, so I recommend reviewing prepare/index.ts primarily in its finished state and not worrying too much about its state commit-by-commit).

📦 Published PR as canary version: 16.10.2--canary.1324.25933365397.0

✨ Test out this PR locally via:

npm install chromatic@16.10.2--canary.1324.25933365397.0
# or 
yarn add chromatic@16.10.2--canary.1324.25933365397.0

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size: 7100 KB
✅ Compared to main: 0 KB 354b119 (7100 KB)

@justin-thurman justin-thurman added patch Auto: Increment the patch version when merged skip-release Auto: Preserve the current version when merged labels May 8, 2026
@codecov

codecov Bot commented May 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.77%. Comparing base (354b119) to head (c1ed781).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1324      +/-   ##
==========================================
+ Coverage   80.75%   80.77%   +0.02%     
==========================================
  Files         224      224              
  Lines        4204     4235      +31     
  Branches     1200     1203       +3     
==========================================
+ Hits         3395     3421      +26     
+ Misses        695      694       -1     
- Partials      114      120       +6     

☔ 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.

@justin-thurman justin-thurman changed the title CAP 4391 Refactor prepare task to use typed inputs and outputs May 8, 2026
Base automatically changed from CAP-4385 to main May 11, 2026 19:06
@justin-thurman justin-thurman force-pushed the CAP-4391 branch 7 times, most recently from 729e9d1 to 50fe741 Compare May 13, 2026 17:34

const apkPath = path.join(ctx.sourceDir, 'storybook.apk');
export async function validateAndroidArtifact(sourceDirectory: string): Promise<boolean> {
const apkPath = path.join(sourceDirectory, 'storybook.apk');

@aikido-pr-checks aikido-pr-checks Bot May 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Potential file inclusion attack via reading file - medium severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.

Show fix
Suggested change
const apkPath = path.join(sourceDirectory, 'storybook.apk');
const resolvedBase = path.resolve(sourceDirectory);
const resolvedTarget = path.resolve(resolvedBase, 'storybook.apk');
const relative = path.relative(resolvedBase, resolvedTarget);
if (relative.startsWith('..') || path.isAbsolute(relative)) {
throw new Error('Invalid file path');
}
const apkPath = resolvedTarget;

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

if (!input.validator(fileInfo, input.browsers).valid && input.buildLogFile) {
try {
const buildLog = readFileSync(ctx.buildLogFile, 'utf8');
const buildLog = readFileSync(input.buildLogFile, 'utf8');

@aikido-pr-checks aikido-pr-checks Bot May 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Potential file inclusion attack via reading file - medium severity
If an attacker can control the input leading into the ReadFile function, they might be able to read sensitive files and launch further attacks with that information.

Show fix
Suggested change
const buildLog = readFileSync(input.buildLogFile, 'utf8');
const buildLogFile = input.buildLogFile;
if (buildLogFile.includes('..') || path.isAbsolute(buildLogFile)) {
throw new Error('Invalid file path');
}
const buildLog = readFileSync(buildLogFile, 'utf8');

Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Auto: Increment the patch version when merged skip-release Auto: Preserve the current version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant