« Oatmeal

Tagged "code"

Follow this tag

In reply to: Code as a Crime Scene

This post describes an interesting approach to using git commit history and metadata to help guide code maintenance. Essentially, when you look at statistics on commits to see which files get updated at the same time, you can begin to get a sense for the logical coupling of the different parts of an application.

I think there is something to be inferred from this with regards to the ability to weaponize/exploit this metadata from git, too…but I’m still noodling on the exact details.

2 sort of silly, yet useful PHP functions to get some basic info about a webpage:

// Used to get a target URL's title
function get_target_title($target_url) {
    if (!function_exists('curl_init')) {
        die('CURL is not installed!');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36');
    $html = curl_exec($ch);
    $dom  = new DOMDocument;
    $title = $dom->getElementsByTagName('title')->item('0')->nodeValue;
    return $title;

Similar, but slightly different…

// Used to get a target URL's metadata, open graph, twitter, etc.
function get_target_metadata($target_url) {
    $url = $target_url;
    $tags = array();
    $tags['url'] = $url;
    $meta_tags = get_meta_tags($url);
    $tags['meta'] = $meta_tags;
    $site_html=  file_get_contents($url);
    preg_match_all('~<\s*meta\s+property="(og:[^"]+)"\s+content="([^"]*)~i', $site_html,$og_matches);
    for($i=0;$i<count($og_matches[1]);$i++) {
    $tags['open graph'] = $og_tags;
    return $tags;