Files
popcyclical-blog-archive/posts/2010-05-22-trust-issues-with-source-code.md
T

20 lines
1.8 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Trust Issues with Source Code"
date: 2010-05-22T21:51:48.2472794-05:00
slug: trust-issues-with-source-code
published: true
---
![Double face palm](http://suptg.thisisnotatrueending.com/archive/2911771/images/1225644751859.jpg)
Digging around in some code circa 6 months ago I discovered a method that I had scrounged from the web and, in my apparent haste at the time, had not build any unit tests.  It was less than 20 lines of code doing some simple array manipulation and it was from a pretty decent site, so it seemed pretty safe.  Its the weekend so I thought, hey, time to plug that gap!  I started with some simple cases and soon realized that one of the execution paths was just … well, *plain wrong.*
Luckily, that behavior wasnt being used anywhere in my project (yet!), but still, it was essentially a land mine waiting for someone to trip it.  My first reaction was “shame on them for posting that without testing it!”  Of course, this code didnt end up in my project because of the author.  It was I who blindly accepted and given it the “its from the internet!”-stamp-of-approval.
Lessons learned today:[![itsfromtheinternet](http://popcyclical.com/content/binary/images/fd79eac90e05_13202/itsfromtheinternet_thumb.png)](http://popcyclical.com/content/binary/images/fd79eac90e05_13202/itsfromtheinternet.png)
- Trust is earned, not given.
- Source code becomes trusted by-way-of thorough unit and functional testing.
- Do not trust untested code from the internet.
- Do not trust untested code from your own keyboard even more so at least on the internet its likely that someone else has reviewed it.
Ive written the author a friendly note with a simple fix its better to diffuse that bomb than let it get somebody else!