lib/rule/validate/codeUsage.js
function validate(harvested, report, next, options) {

    report.setChecklist('CodeUsage', 'Static code analysis');

    var illegalIdentifiers = ['geolocation'];

    function analyze(content, sourceURL, origin) {
        var ast;
        var trace = {
            'trace': {
                'sourceURL': sourceURL
            }
        };

        try {
            ast = esprima.parse(content.toString(), {
                'loc': true,
                'tolerant': true
            });
        } catch (e) {
            report.error('Possible javascript malformed / SyntaxError in content from ' + origin, {
                trace: [
                    {
                        'line': e.lineNumber,
                        'column': e.column,
                        'index': e.index,
                        'sourceURL': sourceURL
                    }
                ]
            });
            return;
        }

        estraverse.traverse(ast, {
            enter: function (node, parent) {
                if (node.type === 'Identifier' && parent.type === 'MemberExpression' && illegalIdentifiers.indexOf(node.name) > -1) {
                    report.error('Please do not "use" the geolocation api', trace);
                } else if (node.type === 'Literal' && illegalIdentifiers.indexOf(node.value) > -1) {
                    report.error('Please do not "use" the geolocation api', trace);
                }
            }
        });
    }

    if (harvested.script.tags) {
        harvested.script.tags.forEach(function (tag) {
            analyze(tag, options.scriptUrl, 'tag');
        });
    }

    if (harvested.script.attributes) {
        harvested.script.attributes.forEach(function (data) {
            data.matches.forEach(function (match) {
                analyze(match.value, '(' + data.tag + ') ' + match.key + '-attribute', 'attribute');
            });
        });
    }

    if (harvested.har.rawFileData) {
        Object.keys(harvested.har.rawFileData).forEach(function (key) {
            var v = harvested.har.rawFileData[key];
            if (v && !v.requestError && v.contentType && v.contentType.indexOf('javascript') > -1 && v.base64Content) {
                analyze(new Buffer(v.base64Content, 'base64').toString('utf8'), v.url, 'file');
            }
        });
    }

    report.exitChecklist();

    next();
}
function validate(harvested, report, next, options) {

    report.setChecklist('CodeUsage', 'Static code analysis');

    var illegalIdentifiers = ['geolocation'];

    function analyze(content, sourceURL, origin) {
        var ast;
        var trace = {
            'trace': {
                'sourceURL': sourceURL
            }
        };

        try {
            ast = esprima.parse(content.toString(), {
                'loc': true,
                'tolerant': true
            });
        } catch (e) {
            report.error('Possible javascript malformed / SyntaxError in content from ' + origin, {
                trace: [
                    {
                        'line': e.lineNumber,
                        'column': e.column,
                        'index': e.index,
                        'sourceURL': sourceURL
                    }
                ]
            });
            return;
        }

        estraverse.traverse(ast, {
            enter: function (node, parent) {
                if (node.type === 'Identifier' && parent.type === 'MemberExpression' && illegalIdentifiers.indexOf(node.name) > -1) {
                    report.error('Please do not "use" the geolocation api', trace);
                } else if (node.type === 'Literal' && illegalIdentifiers.indexOf(node.value) > -1) {
                    report.error('Please do not "use" the geolocation api', trace);
                }
            }
        });
    }

    if (harvested.script.tags) {
        harvested.script.tags.forEach(function (tag) {
            analyze(tag, options.scriptUrl, 'tag');
        });
    }

    if (harvested.script.attributes) {
        harvested.script.attributes.forEach(function (data) {
            data.matches.forEach(function (match) {
                analyze(match.value, '(' + data.tag + ') ' + match.key + '-attribute', 'attribute');
            });
        });
    }

    if (harvested.har.rawFileData) {
        Object.keys(harvested.har.rawFileData).forEach(function (key) {
            var v = harvested.har.rawFileData[key];
            if (v && !v.requestError && v.contentType && v.contentType.indexOf('javascript') > -1 && v.base64Content) {
                analyze(new Buffer(v.base64Content, 'base64').toString('utf8'), v.url, 'file');
            }
        });
    }

    report.exitChecklist();

    next();
}
function validate ( harvested , report , next , options ) { report . setChecklist ( 'CodeUsage' , 'Static code analysis' ) ; var illegalIdentifiers = [ 'geolocation' ] ; function analyze ( content , sourceURL , origin ) { var ast ; var trace = { 'trace' : { 'sourceURL' : sourceURL } } ; try { ast = esprima . parse ( content . toString ( ) , { 'loc' : true , 'tolerant' : true } ) ; } catch ( e ) { report . error ( 'Possible javascript malformed / SyntaxError in content from ' + origin , { trace : [ { 'line' : e . lineNumber , 'column' : e . column , 'index' : e . index , 'sourceURL' : sourceURL } ] } ) ; return ; } estraverse . traverse ( ast , { enter : function ( node , parent ) { if ( node . type === 'Identifier' && parent . type === 'MemberExpression' && illegalIdentifiers . indexOf ( node . name ) > - 1 ) { report . error ( 'Please do not "use" the geolocation api' , trace ) ; } else if ( node . type === 'Literal' && illegalIdentifiers . indexOf ( node . value ) > - 1 ) { report . error ( 'Please do not "use" the geolocation api' , trace ) ; } } } ) ; } if ( harvested . script . tags ) { harvested . script . tags . forEach ( function ( tag ) { analyze ( tag , options . scriptUrl , 'tag' ) ; } ) ; } if ( harvested . script . attributes ) { harvested . script . attributes . forEach ( function ( data ) { data . matches . forEach ( function ( match ) { analyze ( match . value , '(' + data . tag + ') ' + match . key + '-attribute' , 'attribute' ) ; } ) ; } ) ; } if ( harvested . har . rawFileData ) { Object . keys ( harvested . har . rawFileData ) . forEach ( function ( key ) { var v = harvested . har . rawFileData [ key ] ; if ( v && ! v . requestError && v . contentType && v . contentType . indexOf ( 'javascript' ) > - 1 && v . base64Content ) { analyze ( new Buffer ( v . base64Content , 'base64' ) . toString ( 'utf8' ) , v . url , 'file' ) ; } } ) ; } report . exitChecklist ( ) ; next ( ) ; }
navigator.geolocation
navigator . geolocation