New() can panic on OCI specs with a missing root section

オープン 初心者向け
#902 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #903 @Utkarsh-sharma47 による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go

調査の方向性

New() と Get() から開始し、その後、GetUnikernelConfig()、InitialSetup()、Exec() が spec.Root.Path にアクセスする前に使用される検証を追跡します。linux が存在し root が欠落している最小限の OCI spec に対する回帰テストのカバレッジを追加します。New() がそれを validation error で拒否し、nil-pointer panic や無効な Unikontainer を許容しない状態になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug Core enhancement OCI

Description

New() currently validates that the parsed OCI spec contains a linux section, but does not validate that spec.Root is present.

A syntactically valid but structurally incomplete config.json, such as:

{
  "linux": {}
}

can therefore reach code paths that dereference spec.Root.Path, resulting in a nil pointer panic instead of returning a validation error.

I also found that when valid unikernel annotations are present, New() can return successfully while u.Spec.Root == nil, leaving an invalid Unikontainer that may panic later.

Relevant code

New() currently checks:

if spec == nil || spec.Linux == nil {
    return nil, fmt.Errorf("invalid OCI spec: linux section is required")
}

but GetUnikernelConfig() later uses:

rootFSDir := spec.Root.Path

and other paths such as InitialSetup() and Exec() also access u.Spec.Root.Path.

Minimal reproducer

Create a bundle containing:

{
  "linux": {}
}

as config.json and call New() with that bundle.

Actual behavior

urunc can panic with a nil pointer dereference when the configuration fallback path accesses spec.Root.Path.

A spec containing valid unikernel annotations but no root section can also be accepted by New(), leaving Spec.Root == nil.

Expected behavior

Structurally incomplete OCI specs should be be rejected with a validation error, for example:

invalid OCI spec: root section is required

Possible direction

Validate that spec.Root is present before returning from New() / Get(), alongside the existing validation of spec.Linux.

A regression test using a minimal spec with linux present and root missing could cover this case.

主要言語
Go
スター
308
フォーク
222
平均マージ
2日 8時間
マージ済み PR(30日)
43

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

urunc-dev/urunc のほかの issue

urunc-dev/urunc の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。