file in abyss
フォーマット一覧へ戻る

Archive

TAR Tape Archive

複数ファイルを連結して格納するアーカイブ形式。512バイト単位のヘッダとデータブロックで構成されます。

Extensions .tar
MIME application/x-tar

マジックナンバー

ファイルを解析
オフセット 257 ustar magic in POSIX tar header
75 73 74 61 72
ustar

構造

  1. File header block
  2. File data blocks
  3. Padding
  4. Zero blocks

注意点

  • 古いtarにはustarマーカーがない場合があります。gzip圧縮されたtar.gzは先頭がGZIPになります。

判定コード例

SIGNATURE = bytes.fromhex("7573746172")
OFFSET = 257

def is_tar(path: str) -> bool:
    with open(path, "rb") as f:
        f.seek(OFFSET)
        head = f.read(len(SIGNATURE))
    return head == SIGNATURE

実践的な使い方

ユースケース

Tape Archive は圧縮、展開、バックアップ、添付、複数ファイルの検査に使われます。展開前にパス・ファイル数・圧縮後/展開後サイズを検証してください。

よくある判定ミス

  • .tar という拡張子だけではファイルの中身を保証できません。アップロードや変換の処理では、拡張子・MIMEタイプ・先頭バイト・形式固有の構造チェックを組み合わせるべきです。
  • Tape Archive は 75 73 74 61 72 のようなシグネチャで始まりますが、関連するコンテナや破損ファイルでは追加の検証が必要になる場合があります。

セキュリティ上の注意

アーカイブには zip-slip パス、過剰な展開、隠しファイル、二重拡張子が含まれることがあります。展開パスを正規化し、ファイル数とサイズの上限を設けてください。

サンプルの活用

11 個のサンプルで、先頭バイト判定・パーサのエラー・アップロード上限・ダウンロード挙動をテストできます。

サンプルファイル

11 / 11 files
Sample Traits Size Source / license / SHA-256
Arc

Two File TAR

Two File TAR is a Tape Archive sample generated for file format testing. It can be used to test downloads, parsers, previews, and file type detection.

two-files.tar
Type Sample
3.0 KB
Generated CC0 1.0
SHA-256 37ae9233002d2f15ba4b05db98f61bb016cd9ccfba2e29832b798c8fc7ddede5
Download
Arc

Blue Sky TAR

Blue Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

01-blue-sky.tar
Type Sample
3.0 KB
SHA-256 4f2498abfbfb9ee74180bf3a02b3a8f976fd16dc33c134c4c307529d46665609
Download
Arc

Flower Garden TAR

Flower Garden TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

02-flower-garden.tar
Type Sample
4.0 KB
SHA-256 ff19afd6572cafd772d5a916145fac852e97180fd8b2c0ab8b2bd05509c82a55
Download
Arc

Navy Blue Sky TAR

Navy Blue Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

03-navy-blue-sky.tar
Type Sample
5.5 KB
SHA-256 033cb4ba37d05f5256393369723ef400609baca455d8a72d53c145097a4e7c2c
Download
Arc

Nature of the Sky TAR

Nature of the Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

04-nature-sky.tar
Type Sample
6.5 KB
SHA-256 248e75969993dea282935a0309e494434cc97dfaa6b088cf22e216319771a9dd
Download
Arc

Sky Landscape TAR

Sky Landscape TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

05-sky-landscape.tar
Type Sample
7.5 KB
SHA-256 37f26144c9d8cab02adcce041bc704ca1c62f8dfbf371cfc4f36a16c73e7b8cc
Download
Arc

Starry Sky TAR

Starry Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

06-starry-sky.tar
Type Sample
8.5 KB
SHA-256 f6a45473e6b56103b67b0dd72518b907b4c1c1cb2ab885e484625000a655118a
Download
Arc

Blue Night Sky TAR

Blue Night Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

07-blue-night-sky.tar
Type Sample
9.5 KB
SHA-256 c4a343ba04c0a27cd56fa9d5da7acfda7bd6165e1f68b9921f7aabaa45729030
Download
Arc

Hibiscus Flower TAR

Hibiscus Flower TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

08-hibiscus-flower.tar
Type Sample
12 KB
SHA-256 0b5000a03369440888b0a8af7bf783f0b349ccc83a44e48c5a1c76f7ca9d513a
Download
Arc

Arctic Sky TAR

Arctic Sky TAR is a Tape Archive sample based on Wikimedia Commons. It can be used to test downloads, parsers, previews, and file type detection.

09-arctic-sky.tar
Type Sample
12 KB
SHA-256 bff79945ec6c8e58b31a7dc7061bd11ca8eca8b8c11f90920c8c4dfc9fdacc17
Download
Arc

NASA Blue Marble TAR

NASA Blue Marble TAR is a Tape Archive sample based on NASA Image and Video Library. It can be used to test downloads, parsers, previews, and file type detection.

nasa-blue-marble-2012-east.tar
Type Sample
19 KB
SHA-256 5314e1c9674de2f0f3f14d952c33991501d04c902b6f5fa22dc70760bac6da35
Download

よくある質問

Tape Archive のマジックナンバー(ファイルシグネチャ)は?

Tape Archive ファイルはバイトシグネチャ 75 73 74 61 72 ("ustar") で始まります。拡張子に頼らず、この先頭バイトを読み取って形式を判定してください。

Tape Archive のMIMEタイプは?

Tape Archive のMIMEタイプは application/x-tar です。

Tape Archive の拡張子は?

Tape Archive ファイルは .tar 拡張子を使います。拡張子は慣習にすぎず中身を保証しないため、シグネチャや構造のチェックと組み合わせてください。

関連フォーマット