Trap Streets for Code: How Mapmakers Caught Copiers, and How I Do It in Git
In the 1920s, two mapmakers at General Drafting, Otto G. Lindberg and Ernest Alpers, put a town on their map of New York that didn't exist. They called it Agloe, an anagram of their initials, and placed it at a dirt-road crossing in the Catskills. The idea was simple: if Agloe ever showed up on someone else's map, that someone had copied theirs. It did. Agloe turned up on a Rand McNally map. When…
In the 1920s, two mapmakers named Otto G. Lindberg and Ernest Alpers placed a fictitious town called Agloe on their map of New York. The town's purpose was to serve as a trap for anyone who copied their map. Over half a century later, the trap streets concept has evolved, with mapmakers using similar tactics to catch code copiers.
Git history may prove what code a user has committed, but it cannot reveal what code exists elsewhere, unbeknownst to the user. To address this issue, a developer built a tool called TrapR, which utilizes three layers of evidence: markers, canaries, and fingerprints. The markers, akin to the fictional town of Agloe, are unique identifiers planted in source files.
The canaries, similar to the fictional character Lillian Virginia Mountweazel, are small, legitimate-looking functions that, when deleted, break the application. The fingerprints, reminiscent of the road widths that Ordnance Survey used to identify copied maps, analyze the structure of code, such as the sequence of loops, conditionals, and functions, to detect any unauthorized modifications.
TrapR is an open-source Python tool designed to help developers monitor and protect their code across multiple repositories. It functions as a merge gate, automatically marking files with markers and updating a private vault containing the necessary keys. By employing this multi-layered approach, TrapR aims to provide developers with a reliable method for detecting and preventing code duplication.
Rewritten by urgent.news; may contain errors — check the original.