2026年9月5日土曜日

docker compose で起動したコンテナがどの作業ディレクトリで動いているか確認する方法

docker compose で起動したコンテナがどの作業ディレクトリで動いているか確認する方法

概要

docker compose でいろいろなパスで docker compose up -d していると忘れるので一覧で表示する方法を紹介します

コマンド

docker ps -q | xargs -I {} docker inspect -f '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}' {}

2026年9月4日金曜日

GCP の ArtifactRegistry にある latest タグ以外のイメージを一括で削除する方法

GCP の ArtifactRegistry にある latest タグ以外のイメージを一括で削除する方法

概要

CLI を使いましょう

環境

  • macOS 26.6.2
  • gcloud cli 545.0.0

タグの一覧を表示

gcloud artifacts docker images list \
  asia-northeast1-docker.pkg.dev/product-123456/gae-standard/app/default \
  --include-tags --format='get(version,tags)'

対象のタグに絞り込む

gcloud artifacts docker images list \
  asia-northeast1-docker.pkg.dev/product-123456/gae-standard/app/default \
  --include-tags \
  --format='get(version,tags)' |
while read -r version tags; do
  if [[ "$tags" != *latest* ]]; then
    echo ${tags}
    echo ${version}
  fi
done

絞り込んだイメージを削除

gcloud artifacts docker images list \
  asia-northeast1-docker.pkg.dev/product-123456/gae-standard/app/default \
  --include-tags \
  --format='get(version,tags)' |
while read -r version tags; do
  if [[ "$tags" != *latest* ]]; then
    echo ${tags}
    echo ${version}

    gcloud artifacts docker images delete \
      "asia-northeast1-docker.pkg.dev/product-123456/gae-standard/app/default@$version" \
      --delete-tags \
      --quiet
  fi
done

最後に

プロジェクトのIDやリポジトリ名やパッケージ名は適宜変更してください

2026年9月3日木曜日

Xcode26 で ipa ファイルを作成する方法

Xcode26 で ipa ファイルを作成する方法

概要

なぜか xcode からだとエンロール関係でエラーになるので CLI を使いましょう

環境

  • macOS 26.6.2
  • Xcode 26.6 (17F113)
  • iPhone 15

事前準備

  • Xcode に無料の Developer Account でログイン
  • Xcode で開発用の証明書作成
  • iPhone 実機の接続

ビルド: app フォルダの作成

xcodebuild -workspace ios-moributa.xcworkspace \
           -scheme ios-moributa \
           -sdk iphoneos \
           -configuration Release \
           -archivePath ./build/ios-moributa.xcarchive \
           archive

アーカイブ: ipa ファイルの作成

xcodebuild -workspace ios-moributa.xcworkspace \
           -scheme ios-moributa \
           -sdk iphoneos \
           -configuration Release \
           -archivePath ./build/ios-moributa.xcarchive \
           archive

配布設定ファイルの作成

  • vim ExportOptions.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://apple.com">
<plist version="1.0">
<dict>
    <key>method</key>
    <string>development</string> <!-- 開発用証明書(iOS Development)で書き出す -->
    <key>signingStyle</key>
    <string>automatic</string>
</dict>
</plist>

最後に

ワークスペース名やスキーマ名は適宜変更してください

2026年9月2日水曜日

AltStore で the data couldn’t be read because it isn’t in the correct format

AltStore で the data couldn’t be read because it isn’t in the correct format

概要

対応策を紹介します

環境

  • macOS 26.6.2
  • AltServer 1.7.2
  • AltStore 2.2.1

対応策

  • iPhone の wifi をオフにする
  • Mac と有線接続する
  • AltServer 起動
  • AltStore 起動
  • アプリの更新

最後に

macOS をアップデートすると出る気がしなくもないです

2026年8月30日日曜日

semgrep 超入門

semgrep 超入門

概要

SAST しましょう

環境

  • macOS 26.6.2
  • semgrep 1.175.0

インストール

  • brew install semgrep

pip でもインストールできるのでグローバルにインストールしたくない場合は Pipfile や pyproject.toml を使いましょう

スキャン

  • semgrep --config=auto .

初回はルールのダウンロードが走ります
以下のようなエラーが良く出ます

  • CSS のインポート時に integrity がないから XSS されます
  • パスワードや鍵などのセンシティブ情報がコード内に含まれています
  • GithubActions や docker はタグじゃなくてコミットハッシュを指定しましょう、じゃないとサプライチェーンアタックの対象になる可能性があります

などなど出てきます

ルールセット

今回は auto でしたが p/ci や p/python など使えます

https://semgrep.dev/explore

OSS 版だと使えるルールセットが限られていますが Pro 版だとよりたくさんのルールセットが使えます

Gitlab CI

https://docs.semgrep.dev/semgrep-ci/sample-ci-configs

semgrep:
  # A Docker image with Semgrep installed.
  image: semgrep/semgrep
  # Run the "semgrep ci" command on the command line of the docker image.
  script: semgrep ci

  rules:
    # Allow triggering a scan manually from the GitLab UI
    - if: $CI_PIPELINE_SOURCE == "web"
    # Scan changed files in MRs, (diff-aware scanning):
    - if: $CI_MERGE_REQUEST_IID
    # Scan mainline (default) branches and report all findings.
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH

  variables:
    # Connect to Semgrep AppSec Platform through your SEMGREP_APP_TOKEN.
    # Generate a token from Semgrep AppSec Platform > Settings
    # and add it as a variable in your GitLab CI/CD project settings.
    SEMGREP_APP_TOKEN: $SEMGREP_APP_TOKEN

こんな感じらしいです
当然ですがローカルで実行してエラーをすべて解消しないと CI してもエラーになるので注意してください

最後に

semgrep を試してみました
無料版でも十分使えるレベルかなと思います
あとカスタムルールも作成できるので足りなければ自分でルールを作成すれば SAST なり SCA できます

2026年8月24日月曜日

古い認証アルゴリズムの sshd を検証で起動する方法

古い認証アルゴリズムの sshd を検証で起動する方法

概要

検証用途で一時的に起動させる方法を紹介します

環境

  • Ubuntu 24.04
  • openssh-server 9.6p1

ホスト鍵作成

mkdir -p /tmp/sshd-legacy-test
if [ ! -f /tmp/sshd-legacy-test/ssh_host_rsa_key ]; then
ssh-keygen -q -t rsa -b 2048 -f /tmp/sshd-legacy-test/ssh_host_rsa_key -N ''
fi

設定ファイル作成

cat > /tmp/sshd-legacy-test/sshd_config <<'EOF'
Port 2222
ListenAddress 127.0.0.1
HostKey /tmp/sshd-legacy-test/ssh_host_rsa_key
PidFile /tmp/sshd-legacy-test/sshd.pid
LogLevel VERBOSE
UsePAM no
PasswordAuthentication no
KbdInteractiveAuthentication no
ChallengeResponseAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitRootLogin no
AllowUsers devops

X11Forwarding no
AllowTcpForwarding no
PrintMotd no
Subsystem sftp internal-sftp

KexAlgorithms +diffie-hellman-group14-sha1
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
EOF

設定ファイル確認

  • /usr/sbin/sshd -t -f /tmp/sshd-legacy-test/sshd_config

起動

  • /usr/sbin/sshd -D -e -f /tmp/sshd-legacy-test/sshd_config
  • ss -ltn | grep ':2222 '

停止

if [ -f /tmp/sshd-legacy-test/sshd.pid ]; then
kill "$(cat /tmp/sshd-legacy-test/sshd.pid)"
fi

2026年8月15日土曜日

キーチェインアクセスの GUI からパスワードが消せないときの対処方法

キーチェインアクセスの GUI からパスワードが消せないときの対処方法

概要

もうキーチェインアクセスはオワコンですが git などのコマンドは未だにキーチェインアクセスを参照しているのでキーチェインアクセス側に古いパスワードが残っている場合は削除しましょう

環境

  • macOS 26.5.2
  • git 2.55.0

コマンド

security delete-internet-password -s bitbucket.org  

bitbucket.org の部分は適宜変更してください

確認

security find-internet-password -s bitbucket.org

security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain. になれば削除完了です

最後に

なぜか GUI からだと削除できないというなぞの現象が発生した場合は CLI を使いましょう