Skip to content

Add export from zip support'#10051

Merged
joehan merged 4 commits intomainfrom
jh-zippy
Mar 10, 2026
Merged

Add export from zip support'#10051
joehan merged 4 commits intomainfrom
jh-zippy

Conversation

@joehan
Copy link
Copy Markdown
Member

@joehan joehan commented Mar 10, 2026

Description

Add support for running this command against a zip file.

Screenshot 2026-03-09 at 8 01 06 PM

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the studio:export command by introducing direct support for Firebase Studio export .zip files. This streamlines the migration workflow by eliminating the need for manual unzipping, allowing users to provide a zipped archive directly to the command for automatic extraction and processing, simplifying the overall user experience.

Highlights

  • Zip File Support: The studio:export command now directly accepts .zip files as input, automatically unzipping them before processing.
  • Improved Path Resolution: The command intelligently resolves the root path within unzipped directories, especially when a single top-level folder is present, to ensure correct migration.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/commands/studio-export.ts
    • Added functionality to detect and automatically unzip .zip files provided as input to the studio:export command.
    • Implemented logic to correctly identify the root directory within unzipped content, handling common cases where a single top-level folder contains the actual export.
    • Updated the command description to clearly communicate the new .zip file support to users.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a useful feature to allow running the studio:export command directly on a zip file. However, it introduces a critical path traversal vulnerability (Zip Slip) due to improper extraction directory handling and flawed path validation in the underlying unzip logic, making it susceptible to denial-of-service attacks via memory exhaustion or Zip Bombs. Additionally, there are general suggestions, including a high-severity recommendation to prevent potential data loss by checking for an existing extraction directory, and a medium-severity suggestion to use asynchronous I/O for best practices in async functions.

Comment thread src/commands/studio-export.ts Outdated

if (fs.existsSync(rootPath) && fs.statSync(rootPath).isFile() && rootPath.endsWith(".zip")) {
logger.info(`⏳ Unzipping ${rootPath}...`);
const extractPath = rootPath.slice(0, -4);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-high high

The current derivation of extractPath by simply removing the last 4 characters from the ZIP file path is highly problematic. If the ZIP file is named .zip, extractPath could resolve to a parent directory (e.g., /home/user/ for /home/user/.zip), leading to a critical path traversal vulnerability (Zip Slip). This allows files from the archive to be extracted into unintended locations, potentially overwriting sensitive files like .bashrc or SSH keys. Additionally, the isChildDir check in src/unzip.ts is vulnerable to a prefix bypass, allowing writes to sibling directories. This also creates a risk of data loss or corrupted state if an existing directory is overwritten. To remediate, ensure extractPath is always a dedicated, newly created directory, use robust path validation (e.g., path.relative), and consider checking for and preventing overwrites of existing directories, prompting the user to remove them first.

if (fs.existsSync(rootPath) && fs.statSync(rootPath).isFile() && rootPath.endsWith(".zip")) {
logger.info(`⏳ Unzipping ${rootPath}...`);
const extractPath = rootPath.slice(0, -4);
await unzip(rootPath, extractPath);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

security-medium medium

The unzip function called here buffers the entire ZIP archive into memory using fs.promises.readFile. For large archives, this can lead to memory exhaustion and crash the process. Additionally, the extraction process lacks protection against Zip Bombs (highly compressed files that expand to huge sizes), which can lead to disk space exhaustion.

Consider using a streaming ZIP parser to process entries without buffering the entire file, and implement limits on the uncompressed size of extracted files.

Comment on lines +32 to +40
const extractedItems = fs.readdirSync(extractPath);
if (
extractedItems.length === 1 &&
fs.statSync(path.join(extractPath, extractedItems[0])).isDirectory()
) {
rootPath = path.join(extractPath, extractedItems[0]);
} else {
rootPath = extractPath;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The action function is async, so it's a good practice to use asynchronous file system operations instead of synchronous ones like fs.readdirSync and fs.statSync to avoid blocking the Node.js event loop.

      const extractedItems = await fs.promises.readdir(extractPath);
      if (extractedItems.length === 1) {
        const potentialRoot = path.join(extractPath, extractedItems[0]);
        try {
          if ((await fs.promises.stat(potentialRoot)).isDirectory()) {
            rootPath = potentialRoot;
          } else {
            rootPath = extractPath;
          }
        } catch {
          // If stat fails (e.g. broken symlink), fall back to using the extract path.
          rootPath = extractPath;
        }
      } else {
        rootPath = extractPath;
      }

@joehan joehan enabled auto-merge (squash) March 10, 2026 20:23
@joehan joehan merged commit 68caa46 into main Mar 10, 2026
47 checks passed
@joehan joehan deleted the jh-zippy branch March 10, 2026 20:34
andrewbrook pushed a commit that referenced this pull request Mar 25, 2026
* Add export from zip support'

* Emojis are fun

* More minor fixes
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.

3 participants