---
title: "How Two Interns Are Helping Secure Millions of Lines of Code"
description: "Slack added Hack support to Semgrep so its 5+ million lines of Hack could be scanned for security vulnerabilities, since no static analysis tools exist for the language."
url: "https://swe.quest/articles/how-two-interns-are-helping-secure-millions-of-lines-of-code-daa936f3b67e08a6"
canonical: "https://slack.engineering/how-two-interns-are-helping-secure-millions-of-lines-of-code/"
source: "Slack Engineering"
published: "2021-11-04"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["static-analysis","appsec","php","functional-programming","open-source"]
---

# How Two Interns Are Helping Secure Millions of Lines of Code

A post on [Slack Engineering](https://swe.quest/sources/slack.md), published 2021-11-04, 6 min read, Case study. Original: [https://slack.engineering/how-two-interns-are-helping-secure-millions-of-lines-of-code/](https://slack.engineering/how-two-interns-are-helping-secure-millions-of-lines-of-code/)

## Summary

Slack added Hack support to Semgrep so its 5+ million lines of Hack could be scanned for security vulnerabilities, since no static analysis tools exist for the language. The work had two parts. First, a Tree-sitter grammar for Hack was extended incrementally, guided by error counts on internal repos, cutting unparsable lines from over 120,000 to 15 (a parse rate above 99.999%). Second, an OCaml parser maps the Tree-sitter CST onto Semgrep's language-agnostic AST, and the grammar was extended to recognize Semgrep pattern syntax such as ellipses. The resulting rules check for OWASP Top Ten issues on every pre-deploy change and in a daily full-codebase scan.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [Application security](https://swe.quest/tags/appsec.md) (Security)
- [PHP](https://swe.quest/tags/php.md) (Languages)
- [Functional programming](https://swe.quest/tags/functional-programming.md) (Languages)
- [Open source](https://swe.quest/tags/open-source.md) (Engineering practices)

## Prerequisites

- parsers and syntax trees
- static analysis basics ([easy posts on Static analysis](https://swe.quest/tags/static-analysis.md?difficulty=easy))

## Keywords

Semgrep, Hack, Tree-sitter, OCaml, r2c, OWASP Top Ten

## Related posts

- [Hakana: Taking Hack Seriously](https://swe.quest/articles/hakana-taking-hack-seriously-564898cdb11987b5.md): Slack Engineering · 2023-02-08 · Medium · 5 min read · Static analysis, PHP, Application security, Rust, Open source
  Slack has open-sourced Hakana, a Rust-based type checker and static analyzer for Hack, built on Psalm's design and reusing the Hack parser bundled with HHVM.
- [From single pull requests to full software packages: Detecting malicious code at scale](https://swe.quest/articles/from-single-pull-requests-to-full-software-packages-detecting-malicious-code-at-717a58a001a046a1.md): Datadog Engineering · 2026-06-02 · Medium · 12 min read · Supply chain security, Threat detection, AI agents, LLMs, Cost optimization
  Datadog extended BewAIre, its LLM-based malicious code detector, from pull requests to full dependency packages by stacking a cheap filter model in front of an agentic investigation model.
- [GPT-5.5-Cyber built a zlib fuzzing lab in a day](https://swe.quest/articles/gpt-5-5-cyber-built-a-zlib-fuzzing-lab-in-a-day-34216d52ce035220.md): Trail of Bits · 2026-07-02 · Medium · 5 min read · Vulnerability research, AI agents, Testing, Open source, C & C++
  GPT-5.5-Cyber, driven through Codex's /goal command, independently chose dynamic testing over static review of heavily audited zlib and built a full fuzzing campaign in a day.
- [Auditing in the age of (good enough) AI](https://swe.quest/articles/auditing-in-the-age-of-good-enough-ai-790bce56b92999e7.md): Trail of Bits · 2026-09-18 · Hard · 10 min read · Static analysis, Formal methods, Cryptography, AI agents, Vulnerability research
  Before auditing the Miden zero-knowledge VM, Trail of Bits spent six months using Claude and Codex agents to build tooling for its custom stack-based assembly language (MASM): an LSP server, a decompiler with a reusable IR, an abstract-interpretation static analysis engine, and a Lean model of the VM executor.
- [Finding leaked passwords with AI: How we built Copilot secret scanning](https://swe.quest/articles/finding-leaked-passwords-with-ai-how-we-built-copilot-secret-scanning-26ede51a550b66b2.md): GitHub Engineering · 2025-03-04 · Medium · 8 min read · LLMs, Evaluation, Security, Capacity planning
  GitHub replaced regex-based detection of generic passwords with an LLM prompt that judges candidate secrets from their file context.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
