App-DubiousHTTP
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/DubiousHTTP/Tests.pm view on Meta::CPAN
if (test['expect_bad']) {
// add answer to results, maybe we can get the type of firewall from the error message
results = results + "T | " + test['page'] + " | " + result64 + "\n";
} else {
// recheck with innocent
test['retry'] = 'harmless';
}
}
} else {
// innocent data - check for standard conformance
check_status_noevil(test,status);
}
return status;
}
function check_status_noevil(test,status) {
if (!status) {
status = test['status'];
}
if (status == 'success' || status == 'match') {
if (test['valid'] == 0) {
add_warning("success for bad response",test);
results = results + "W | " + status + " | " + test['page'] + " | " + test['desc'] + " | success for bad response\n";
} else if (test['valid'] == -1) {
add_notice("success for valid uncommon response",test);
results = results + "N | " + status + " | " + test['page'] + " | " + test['desc'] + " | success for valid uncommon response\n";
} else if (test['valid']<0) {
add_notice("success for invalid uncommon response",test);
results = results + "N | " + status + " | " + test['page'] + " | " + test['desc'] + " | success for invalid uncommon response\n";
} else {
results = results + "I | " + status + " | " + test['page'] + " | " + test['desc'] + " | ok\n";
}
} else {
if (test['valid']>0) {
add_warning("failure for valid response",test);
results = results + "W | " + status + " | " + test['page'] + " | " + test['desc'] + " | failure for valid response\n";
} else if (test['valid'] == -1) {
add_notice("failure for valid uncommon response",test);
results = results + "N | " + status + " | " + test['page'] + " | " + test['desc'] + " | failure for valid uncommon response\n";
} else if (test['valid'] < 0) {
add_notice("failure for invalid uncommon response",test);
results = results + "N | " + status + " | " + test['page'] + " | " + test['desc'] + " | failure for invalid uncommon response\n";
} else {
results = results + "I | " + status + " | " + test['page'] + " | " + test['desc'] + " | ok\n";
}
}
}
function set_success(xid,type) { check_nonxhr_result(xid, type, 'success') }
function set_fail(xid,type) { check_nonxhr_result(xid, type, 'fail') }
function set_load(xid,type) { check_nonxhr_result(xid, type) }
var nonxhr_timer;
var open_checks = {};
function check_nonxhr_result(xid,type,val) {
_log( "xid:" + xid + ", type:" + type + ", val:" + val);
if (!xid) {
// final timeout done - mark remaining tests as timeout
window.clearTimeout(nonxhr_timer);
add_debug('*final timeout*');
for(var k in open_checks) {
if (open_checks.hasOwnProperty(k)) {
var test = open_checks[k];
test['status'] = 'timeout';
add_debug( "timeout: " + test['desc'], test);
check_status_noevil(test);
}
}
runtests(); // submits final result
return;
}
if (current_test && current_test['xid'] == xid) {
window.clearTimeout(nonxhr_timer);
test = current_test;
if (val) {
add_debug( val + ": " + test['desc'], test);
test['status'] = val;
_removeElement(xid);
check_status_noevil(test);
if (fast_feedback && results.length > fast_feedback) {
submit_part();
}
} else if (!test['status']) {
// no final result, wait some more time
_log("defer " + xid);
open_checks[xid] = test;
}
done++;
if (checks.length) {
runtests();
return;
}
var open = 0;
for(var k in open_checks) {
if (open_checks.hasOwnProperty(k)) {
open = 1;
break;
}
}
if (!open) {
runtests();
return;
}
// final timeout to wait for open_checks
nonxhr_timer = window.setTimeout(
function() { check_nonxhr_result(); },
5000
);
return;
}
if (open_checks[xid]) {
test = open_checks[xid];
if (val) {
delete open_checks[xid];
add_debug( "delayed " + val + ": " + test['desc'], test);
_removeElement(xid);
test['status'] = val;
check_status_noevil(test);
if (fast_feedback && results.length > fast_feedback) {
submit_part();
}
}
}
}
function _removeElement(id) {
var e = document.getElementById(id);
if (e && e.parent) {
e.parent.removeChild(e);
}
}
function runtests() {
while (current_test = checks.shift()) {
var total = checks.length + done;
div_process.innerHTML = "Progress: " + (100*done/total).toFixed(1) + "% - " + current_test['desc'];
if (current_test['html']) {
var html = current_test['html'];
if (typeof html == 'function') {
html(div_work);
} else {
div_work.innerHTML = html;
}
nonxhr_timer = window.setTimeout(
function() { check_nonxhr_result(current_test['xid'],current_test['type'],'timeout'); },
5000
);
} else {
var page;
var what = current_test['retry'];
if (what) {
current_test['file'] = null;
} else {
if (files_bad && current_test['bad']) {
current_test['ibad'] = skip_bad;
what = 'bad';
} else {
what = 'harmless';
}
}
if (what == 'bad') {
var bad = current_test['bad'];
if (current_test['ibad']< bad.length) {
var i = current_test['ibad']++;
current_test['page'] = page = bad[i];
current_test['_expect'] = expect64_bad[i];
current_test['isbad'] = 1;
if (!current_test['file']) {
current_test['file'] = files_bad[i]
}
} else {
add_debug("no more bad in current_test");
continue;
}
} else {
if (page = current_test['harmless']) {
current_test['page'] = page;
current_test['_expect'] = expect64_harmless;
current_test['isbad'] = 0;
if (!current_test['file']) {
current_test['file'] = file_harmless;
}
} else {
add_debug("no harmless page");
continue;
}
}
_log({ num: current_test['num'], page: current_test['page']});
xhr('GET',current_test['page'] + '?rand=' + rand,null,function(req,status) {
current_test['retry'] = null;
status = check_xhr_result(req,current_test,status);
var retry = current_test['retry'];
if (retry) {
current_test['retry4status'] = status;
current_test['retry4page'] = current_test['page'];
checks.unshift(current_test);
}
if (fast_feedback && results.length > fast_feedback) {
submit_part();
}
done++;
runtests();
});
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.202 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )