Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
エラーログのマスキングの仕組みづくりに役立ったASTの話
Search
Kenichi Shihota
February 24, 2026
Programming
0
110
エラーログのマスキングの仕組みづくりに役立ったASTの話
ASTを活用し、エラーマスキング解除の漏れを警告するLinterを実装した事例を紹介しています。
Kenichi Shihota
February 24, 2026
Tweet
Share
Other Decks in Programming
See All in Programming
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
160
あなたはユーザーではない #PdENight
kajitack
4
300
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
980
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
190
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
110
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
500
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
180
オブザーバビリティ駆動開発って実際どうなの?
yohfee
3
680
CSC307 Lecture 13
javiergs
PRO
0
310
CSC307 Lecture 12
javiergs
PRO
0
460
Rails Girls Tokyo 18th GMO Pepabo Sponsor Talk
yutokyokutyo
0
190
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
160
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Making the Leap to Tech Lead
cromwellryan
135
9.8k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
230
Technical Leadership for Architectural Decision Making
baasie
3
270
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
220
Mobile First: as difficult as doing things right
swwweet
225
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.1k
How GitHub (no longer) Works
holman
316
140k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
WCS-LA-2024
lcolladotor
0
470
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4k
Transcript
エラーログのマスキングの仕組みづくりに 役⽴ったASTの話
⾃⼰紹介 Kumoichi14 経歴: 新卒1年⽬ 職種: バックエンドエンジニア 趣味: スマブラ(⼤乱闘)
プレゼンテーション構成 ‧マスキングを導⼊したことにより出てきた課題 ‧課題解決にASTがどう役⽴ったか ‧マスキングとマスキング解除の挙動の紹介 はじまり
1. コード上での呼び出し 2. ログへの出⼒結果 ※変数 title の値が⾃動的に検知‧加⼯されます。 errorsx.Errorf(“invalid title: %s”,
title) invalid title: ***** マスキングの挙動例 string, struct など
1. コード上での呼び出し 2. ログへの出⼒結果 errorsx.Errorf(“invalid title: %s”, mask.WithoutMasking(title)) invalid title:
GolangTokyo マスキングの対象外とする挙動例
なぜマスキングされる型に対して、マスキング対象外と する関数を毎回つけるのか
この「付与忘れ」を仕組みで防ぎたかった マスキング対象外とする関数(withoutMasking) をつけ忘れる可能性があった 課題
ASTを活用してLinterを作れば、特定の関数の付与のし 忘れなどを検知できると知った
コードを「情報のツリー」として捉える ソースコードを単なる⽂字列ではなく、コンピューターが理解 できる階層構造(⽊構造)に変換したものです。 • 役割の明確化: パッケージ名、関数名、引数、リテラル値などを、 意味を持つ最小単位(ノード)として個別に識別。 AST(抽象構⽂⽊)とは
CallExpr 関数呼び出し全体 FUN(SelectorExpr) 呼び出す対象 X(Ident) 受信者 / 左側 SEL(Ident) 選択子
/ 右側 Arg([]AST.Expr) 引数リスト Arg[0](BasicLit) リテラル値 Arg[1](Ident) 変数 errorsx.Errorf(“invalid title: %s”, title) errorsx.Errorf errorsx Errorf “invalid title: %s“ title ["invalid title: %s", title] errorsx.Errorf(“invalid title: %s”, title)
コードの差分を取得 ① パッケージ名がerrorsxを含むものがあるかを確かめる ② 関数名がErrofであることを確かめる ③ 変数(title)がWithoutMasking付与対象内の型であることを確かめる ここまで確認が取れたら、警告を出す mask.WithoutMasking()つけ忘れ検知の流れ
CallExpr 関数呼び出し全体 FUN(SelectorExpr) 呼び出す対象 SEL(IDENT) 選択子 Arg([]AST.EXPR) 引数リスト Arg[0](BASICLIT) リテラル値
Arg[1](IDENT) 変数 errorsx.Errorf(“invalid title: %s”, title) errorsx.Errorf Errorf “invalid title: %s“ title ["invalid title: %s", title] X(Ident) 受信者 / 左側 SEL(Ident) 選択子 / 右側 errorsx Errorf “errorsx”であることを確認
CallExpr 関数呼び出し全体 FUN(SelectorExpr) 呼び出す対象 Arg([]AST.EXPR) 引数リスト Arg[0](BASICLIT) リテラル値 Arg[1](IDENT) 変数
errorsx.Errorf(“invalid title: %s”, title) errorsx.Errorf Errorf “invalid title: %s“ title ["invalid title: %s", title] “Errorf”であることを確認 X(Ident) 受信者 / 左側 SEL(Ident) 選択子 / 右側 errorsx Errorf
CallExpr 関数呼び出し全体 FUN(SelectorExpr) 呼び出す対象 Arg([]AST.EXPR) 引数リスト Arg[0](BASICLIT) リテラル値 Arg[1](IDENT) 変数
errorsx.Errorf(“invalid title: %s”, title) errorsx.Errorf “invalid title: %s“ title ["invalid title: %s", title] titleがマスキング対象内の型であるこ とを確認(analysis.Pass.TypesInfoが型 情報を持っている) titleの型はstringであるので マスキング対象内の型 X(Ident) 受信者 / 左側 SEL(Ident) 選択子 / 右側 errorsx Errorf
Linterでの関数付与忘れの検知 errorsx.Errorf(“invalid title: %s”, title) ASTを利用した検知の仕組み エラーログに出していい値なことを確認したうえで、 mask.WithoutMaskingを付与してください
学び
ご静聴ありがとうございました