Bug 1249595 - Enable 11 more ESLint rules for PSM. r=keeler

MozReview-Commit-ID: FxS9SPRMMxf
This commit is contained in:
Cykesiopka 2016-02-26 12:35:34 -08:00
parent b3be7b1717
commit d36ccebcb0
22 changed files with 156 additions and 128 deletions

View File

@ -6,12 +6,18 @@
// Require spacing around => // Require spacing around =>
"arrow-spacing": 2, "arrow-spacing": 2,
// Always require spacing around a single line block
"block-spacing": 2,
// No space before always a space after a comma // No space before always a space after a comma
"comma-spacing": [2, {"before": false, "after": true}], "comma-spacing": [2, {"before": false, "after": true}],
// Commas at the end of the line not the start // Commas at the end of the line not the start
"comma-style": 2, "comma-style": 2,
// Don't require spaces around computed properties
"computed-property-spacing": [2, "never"],
// Functions must always return something or nothing // Functions must always return something or nothing
"consistent-return": 2, "consistent-return": 2,
@ -33,6 +39,12 @@
// Always require parenthesis for new calls // Always require parenthesis for new calls
"new-parens": 2, "new-parens": 2,
// Use [] instead of Array()
"no-array-constructor": 2,
// Disallow use of debugger
"no-debugger": 2,
// No duplicate arguments in function declarations // No duplicate arguments in function declarations
"no-dupe-args": 2, "no-dupe-args": 2,
@ -45,6 +57,9 @@
// No labels // No labels
"no-labels": 2, "no-labels": 2,
// If an if block ends with a return no need for an else block
"no-else-return": 2,
// No empty character classes in regex // No empty character classes in regex
"no-empty-character-class": 2, "no-empty-character-class": 2,
@ -69,21 +84,41 @@
// No odd whitespace characters // No odd whitespace characters
"no-irregular-whitespace": 2, "no-irregular-whitespace": 2,
// No single if block inside an else block
"no-lonely-if": 2,
// No mixing spaces and tabs in indent // No mixing spaces and tabs in indent
"no-mixed-spaces-and-tabs": [2, "smart-tabs"], "no-mixed-spaces-and-tabs": [2, "smart-tabs"],
// No unnecessary spacing
"no-multi-spaces": [2, { "exceptions": {
"AssignmentExpression": true,
"VariableDeclarator": true,
"ArrayExpression": true,
"ObjectExpression": true
}}],
// No reassigning native JS objects // No reassigning native JS objects
"no-native-reassign": 2, "no-native-reassign": 2,
// No (!foo in bar) // No (!foo in bar)
"no-negated-in-lhs": 2, "no-negated-in-lhs": 2,
// Nested ternary statements are confusing
"no-nested-ternary": 2,
// Use {} instead of new Object() // Use {} instead of new Object()
"no-new-object": 2, "no-new-object": 2,
// No Math() or JSON() // No Math() or JSON()
"no-obj-calls": 2, "no-obj-calls": 2,
// No octal literals
"no-octal": 2,
// No redeclaring variables
"no-redeclare": 2,
// No unnecessary comparisons // No unnecessary comparisons
"no-self-compare": 2, "no-self-compare": 2,
@ -111,10 +146,15 @@
// Always require semicolon at end of statement // Always require semicolon at end of statement
"semi": [2, "always"], "semi": [2, "always"],
// Require space after keywords
// Note: Replaced by keyword-spacing in ESLint v2.0.
"space-after-keywords": 2,
// Require space before blocks // Require space before blocks
"space-before-blocks": 2, "space-before-blocks": 2,
// Require spaces before finally, catch, etc. // Require spaces before finally, catch, etc.
// Note: Replaced by keyword-spacing in ESLint v2.0.
"space-before-keywords": [2, "always"], "space-before-keywords": [2, "always"],
// No space padding in parentheses // No space padding in parentheses
@ -124,6 +164,7 @@
"space-infix-ops": 2, "space-infix-ops": 2,
// Require spaces after return, throw and case // Require spaces after return, throw and case
// Note: Replaced by keyword-spacing in ESLint v2.0.
"space-return-throw-case": 2, "space-return-throw-case": 2,
// ++ and -- should not need spacing // ++ and -- should not need spacing

View File

@ -28,7 +28,7 @@ function onLoad()
var rememberSetting = true; var rememberSetting = true;
var pref = Components.classes['@mozilla.org/preferences-service;1'] var pref = Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService); .getService(Components.interfaces.nsIPrefService);
if (pref) { if (pref) {
pref = pref.getBranch(null); pref = pref.getBranch(null);
try { try {

View File

@ -22,40 +22,36 @@ function setWindowName()
var confirm; var confirm;
var impact; var impact;
if(typeFlag == "mine_tab") switch (typeFlag) {
{ case "mine_tab":
title = bundle.getString("deleteUserCertTitle"); title = bundle.getString("deleteUserCertTitle");
confirm = bundle.getString("deleteUserCertConfirm"); confirm = bundle.getString("deleteUserCertConfirm");
impact = bundle.getString("deleteUserCertImpact"); impact = bundle.getString("deleteUserCertImpact");
} break;
else if(typeFlag == "websites_tab") case "websites_tab":
{ title = bundle.getString("deleteSslCertTitle3");
title = bundle.getString("deleteSslCertTitle3"); confirm = bundle.getString("deleteSslCertConfirm3");
confirm = bundle.getString("deleteSslCertConfirm3"); impact = bundle.getString("deleteSslCertImpact3");
impact = bundle.getString("deleteSslCertImpact3"); break;
} case "ca_tab":
else if(typeFlag == "ca_tab") title = bundle.getString("deleteCaCertTitle2");
{ confirm = bundle.getString("deleteCaCertConfirm2");
title = bundle.getString("deleteCaCertTitle2"); impact = bundle.getString("deleteCaCertImpactX2");
confirm = bundle.getString("deleteCaCertConfirm2"); break;
impact = bundle.getString("deleteCaCertImpactX2"); case "others_tab":
} title = bundle.getString("deleteEmailCertTitle");
else if(typeFlag == "others_tab") confirm = bundle.getString("deleteEmailCertConfirm");
{ impact = bundle.getString("deleteEmailCertImpactDesc");
title = bundle.getString("deleteEmailCertTitle"); break;
confirm = bundle.getString("deleteEmailCertConfirm"); case "orphan_tab":
impact = bundle.getString("deleteEmailCertImpactDesc"); title = bundle.getString("deleteOrphanCertTitle");
} confirm = bundle.getString("deleteOrphanCertConfirm");
else if(typeFlag == "orphan_tab") impact = "";
{ break;
title = bundle.getString("deleteOrphanCertTitle"); default:
confirm = bundle.getString("deleteOrphanCertConfirm"); return;
impact = "";
}
else
{
return;
} }
var confirReference = document.getElementById('confirm'); var confirReference = document.getElementById('confirm');
var impactReference = document.getElementById('impact'); var impactReference = document.getElementById('impact');
document.title = title; document.title = title;

View File

@ -190,7 +190,7 @@ function enableButtons()
if (selected_token != null) { if (selected_token != null) {
if (selected_token.needsLogin() || !(selected_token.needsUserInit)) { if (selected_token.needsLogin() || !(selected_token.needsUserInit)) {
pw_toggle = "false"; pw_toggle = "false";
if(selected_token.needsLogin()) { if (selected_token.needsLogin()) {
if (selected_token.isLoggedIn()) { if (selected_token.isLoggedIn()) {
logout_toggle = "false"; logout_toggle = "false";
} else { } else {

View File

@ -104,7 +104,7 @@ function checkCert() {
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
try { try {
if(uri) { if (uri) {
req.open('GET', uri.prePath, false); req.open('GET', uri.prePath, false);
req.channel.notificationCallbacks = new badCertListener(); req.channel.notificationCallbacks = new badCertListener();
req.send(null); req.send(null);

View File

@ -28,7 +28,7 @@ function onLoad()
try { try {
params = window.arguments[0].QueryInterface(nsIDialogParamBlock); params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
tokenName = params.GetString(1); tokenName = params.GetString(1);
} catch(exception) { } catch (e) {
// this should not happen. // this should not happen.
// previously we had self.name, but self.name was a bad idea // previously we had self.name, but self.name was a bad idea
// as window name must be a subset of ascii, and the code was // as window name must be a subset of ascii, and the code was

View File

@ -141,8 +141,7 @@ function exportToFile(parent, cert)
fos.init(file, 0x02 | 0x08 | 0x20, 0o0644, 0); fos.init(file, 0x02 | 0x08 | 0x20, 0o0644, 0);
written = fos.write(content, content.length); written = fos.write(content, content.length);
fos.close(); fos.close();
} } catch (e) {
catch(e) {
switch (e.result) { switch (e.result) {
case Components.results.NS_ERROR_FILE_ACCESS_DENIED: case Components.results.NS_ERROR_FILE_ACCESS_DENIED:
msg = bundle.getString("writeFileAccessDenied"); msg = bundle.getString("writeFileAccessDenied");

View File

@ -43,8 +43,7 @@ function resetPassword()
wallet.WALLET_DeleteAll(); wallet.WALLET_DeleteAll();
} }
} }
} } catch (e) {
catch(e) {
// wallet.crypto pref is missing // wallet.crypto pref is missing
} }
} }

View File

@ -77,18 +77,10 @@ function setWindowName()
var certDetails = bundle.getString('certDetails'); var certDetails = bundle.getString('certDetails');
if (myName != "") { if (myName != "") {
document.title = certDetails + '"' + myName + '"'; // XXX l10n? document.title = certDetails + '"' + myName + '"'; // XXX l10n?
// Get the token
// XXX ignore this for now. NSS will find the cert on a token
// by "tokenname:certname", which is what we have.
//var tokenName = "";
//var pk11db = Components.classes[nsPK11TokenDB].getService(nsIPK11TokenDB);
//var token = pk11db.findTokenByName(tokenName);
//var cert = certdb.findCertByNickname(token, myName);
cert = certdb.findCertByNickname(myName); cert = certdb.findCertByNickname(myName);
} else { } else {
var params = window.arguments[0].QueryInterface(nsIDialogParamBlock); var params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
var cert = params.objects.queryElementAt(0, nsIX509Cert); cert = params.objects.queryElementAt(0, nsIX509Cert);
document.title = certDetails + '"' + cert.windowTitle + '"'; // XXX l10n? document.title = certDetails + '"' + cert.windowTitle + '"'; // XXX l10n?
} }

View File

@ -103,17 +103,13 @@ function postMsg(message)
function finish() function finish()
{ {
if (history.length == 1 && !bypassNavigationTest) if (history.length == 1 && !bypassNavigationTest) {
{ window.setTimeout(() => {
window.setTimeout(function()
{
window.location.assign(navigateToInsecure ? window.location.assign(navigateToInsecure ?
"http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/backward.html" : "http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/backward.html" :
"https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/backward.html"); "https://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/backward.html");
}, 0); }, 0);
} } else {
else
{
postMsg("done"); postMsg("done");
window.close(); window.close();
} }
@ -193,7 +189,11 @@ function waitForSecurityState(expectedState, callback)
var roundsLeft = 200; // Wait for 20 seconds (=200*100ms) var roundsLeft = 200; // Wait for 20 seconds (=200*100ms)
var interval = var interval =
window.setInterval(function() { window.setInterval(function() {
isSecurityState(expectedState, "", function(isok) {if (isok) {roundsLeft = 0;}}); isSecurityState(expectedState, "", isok => {
if (isok) {
roundsLeft = 0;
}
});
if (!roundsLeft--) { if (!roundsLeft--) {
window.clearInterval(interval); window.clearInterval(interval);
callback(); callback();

View File

@ -17,19 +17,15 @@
function runTest() function runTest()
{ {
isSecurityState("secure"); isSecurityState("secure");
window.setTimeout(function() window.setTimeout(() => {
{ try {
try
{
var req = new XMLHttpRequest(); var req = new XMLHttpRequest();
req.open("GET", "http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/alloworigin.sjs", false); req.open("GET", "http://example.com/tests/security/manager/ssl/tests/mochitest/mixedcontent/alloworigin.sjs", false);
req.send(null); req.send(null);
// Change should be immediate, the request was sent synchronously // Change should be immediate, the request was sent synchronously
isSecurityState("broken", "security broken after insecure XHR"); isSecurityState("broken", "security broken after insecure XHR");
} } catch (ex) {
catch (ex)
{
ok(false, ex); ok(false, ex);
} }

View File

@ -109,7 +109,7 @@
// listen for calls back from the sts-setting iframe and then // listen for calls back from the sts-setting iframe and then
// the verification frames. // the verification frames.
window.addEventListener("message", onMessageReceived, false); window.addEventListener("message", onMessageReceived, false);
window.addEventListener('load', function() {startRound('plain');}, false); window.addEventListener("load", () => { startRound("plain"); }, false);
</script> </script>
</head> </head>

View File

@ -33,49 +33,49 @@ const MOZILLA_PKIX_ERROR_BASE = Ci.nsINSSErrorsService.MOZILLA_PKIX_ERROR_BASE;
const PRErrorCodeSuccess = 0; const PRErrorCodeSuccess = 0;
// Sort in numerical order // Sort in numerical order
const SEC_ERROR_INVALID_TIME = SEC_ERROR_BASE + 8; const SEC_ERROR_INVALID_TIME = SEC_ERROR_BASE + 8;
const SEC_ERROR_BAD_DER = SEC_ERROR_BASE + 9; const SEC_ERROR_BAD_DER = SEC_ERROR_BASE + 9;
const SEC_ERROR_BAD_SIGNATURE = SEC_ERROR_BASE + 10; const SEC_ERROR_BAD_SIGNATURE = SEC_ERROR_BASE + 10;
const SEC_ERROR_EXPIRED_CERTIFICATE = SEC_ERROR_BASE + 11; const SEC_ERROR_EXPIRED_CERTIFICATE = SEC_ERROR_BASE + 11;
const SEC_ERROR_REVOKED_CERTIFICATE = SEC_ERROR_BASE + 12; // -8180 const SEC_ERROR_REVOKED_CERTIFICATE = SEC_ERROR_BASE + 12;
const SEC_ERROR_UNKNOWN_ISSUER = SEC_ERROR_BASE + 13; const SEC_ERROR_UNKNOWN_ISSUER = SEC_ERROR_BASE + 13;
const SEC_ERROR_UNTRUSTED_ISSUER = SEC_ERROR_BASE + 20; // -8172 const SEC_ERROR_UNTRUSTED_ISSUER = SEC_ERROR_BASE + 20;
const SEC_ERROR_UNTRUSTED_CERT = SEC_ERROR_BASE + 21; // -8171 const SEC_ERROR_UNTRUSTED_CERT = SEC_ERROR_BASE + 21;
const SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE = SEC_ERROR_BASE + 30; // -8162 const SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE = SEC_ERROR_BASE + 30;
const SEC_ERROR_CA_CERT_INVALID = SEC_ERROR_BASE + 36; const SEC_ERROR_CA_CERT_INVALID = SEC_ERROR_BASE + 36;
const SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION = SEC_ERROR_BASE + 41; const SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION = SEC_ERROR_BASE + 41;
const SEC_ERROR_INADEQUATE_KEY_USAGE = SEC_ERROR_BASE + 90; // -8102 const SEC_ERROR_INADEQUATE_KEY_USAGE = SEC_ERROR_BASE + 90;
const SEC_ERROR_INADEQUATE_CERT_TYPE = SEC_ERROR_BASE + 91; // -8101 const SEC_ERROR_INADEQUATE_CERT_TYPE = SEC_ERROR_BASE + 91;
const SEC_ERROR_CERT_NOT_IN_NAME_SPACE = SEC_ERROR_BASE + 112; // -8080 const SEC_ERROR_CERT_NOT_IN_NAME_SPACE = SEC_ERROR_BASE + 112;
const SEC_ERROR_CERT_BAD_ACCESS_LOCATION = SEC_ERROR_BASE + 117; // -8075 const SEC_ERROR_CERT_BAD_ACCESS_LOCATION = SEC_ERROR_BASE + 117;
const SEC_ERROR_OCSP_MALFORMED_REQUEST = SEC_ERROR_BASE + 120; const SEC_ERROR_OCSP_MALFORMED_REQUEST = SEC_ERROR_BASE + 120;
const SEC_ERROR_OCSP_SERVER_ERROR = SEC_ERROR_BASE + 121; // -8071 const SEC_ERROR_OCSP_SERVER_ERROR = SEC_ERROR_BASE + 121;
const SEC_ERROR_OCSP_TRY_SERVER_LATER = SEC_ERROR_BASE + 122; const SEC_ERROR_OCSP_TRY_SERVER_LATER = SEC_ERROR_BASE + 122;
const SEC_ERROR_OCSP_REQUEST_NEEDS_SIG = SEC_ERROR_BASE + 123; const SEC_ERROR_OCSP_REQUEST_NEEDS_SIG = SEC_ERROR_BASE + 123;
const SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST = SEC_ERROR_BASE + 124; const SEC_ERROR_OCSP_UNAUTHORIZED_REQUEST = SEC_ERROR_BASE + 124;
const SEC_ERROR_OCSP_UNKNOWN_CERT = SEC_ERROR_BASE + 126; // -8066 const SEC_ERROR_OCSP_UNKNOWN_CERT = SEC_ERROR_BASE + 126;
const SEC_ERROR_OCSP_MALFORMED_RESPONSE = SEC_ERROR_BASE + 129; const SEC_ERROR_OCSP_MALFORMED_RESPONSE = SEC_ERROR_BASE + 129;
const SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE = SEC_ERROR_BASE + 130; const SEC_ERROR_OCSP_UNAUTHORIZED_RESPONSE = SEC_ERROR_BASE + 130;
const SEC_ERROR_OCSP_OLD_RESPONSE = SEC_ERROR_BASE + 132; const SEC_ERROR_OCSP_OLD_RESPONSE = SEC_ERROR_BASE + 132;
const SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE = SEC_ERROR_BASE + 141; // -8051 const SEC_ERROR_UNSUPPORTED_ELLIPTIC_CURVE = SEC_ERROR_BASE + 141;
const SEC_ERROR_OCSP_INVALID_SIGNING_CERT = SEC_ERROR_BASE + 144; const SEC_ERROR_OCSP_INVALID_SIGNING_CERT = SEC_ERROR_BASE + 144;
const SEC_ERROR_POLICY_VALIDATION_FAILED = SEC_ERROR_BASE + 160; // -8032 const SEC_ERROR_POLICY_VALIDATION_FAILED = SEC_ERROR_BASE + 160;
const SEC_ERROR_OCSP_BAD_SIGNATURE = SEC_ERROR_BASE + 157; const SEC_ERROR_OCSP_BAD_SIGNATURE = SEC_ERROR_BASE + 157;
const SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED = SEC_ERROR_BASE + 176; const SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED = SEC_ERROR_BASE + 176;
const SSL_ERROR_NO_CYPHER_OVERLAP = SSL_ERROR_BASE + 2; const SSL_ERROR_NO_CYPHER_OVERLAP = SSL_ERROR_BASE + 2;
const SSL_ERROR_BAD_CERT_DOMAIN = SSL_ERROR_BASE + 12; const SSL_ERROR_BAD_CERT_DOMAIN = SSL_ERROR_BASE + 12;
const SSL_ERROR_BAD_CERT_ALERT = SSL_ERROR_BASE + 17; const SSL_ERROR_BAD_CERT_ALERT = SSL_ERROR_BASE + 17;
const SSL_ERROR_WEAK_SERVER_CERT_KEY = SSL_ERROR_BASE + 132; const SSL_ERROR_WEAK_SERVER_CERT_KEY = SSL_ERROR_BASE + 132;
const MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE = MOZILLA_PKIX_ERROR_BASE + 0; const MOZILLA_PKIX_ERROR_KEY_PINNING_FAILURE = MOZILLA_PKIX_ERROR_BASE + 0;
const MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY = MOZILLA_PKIX_ERROR_BASE + 1; const MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY = MOZILLA_PKIX_ERROR_BASE + 1;
const MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE = MOZILLA_PKIX_ERROR_BASE + 2; // -16382 const MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE = MOZILLA_PKIX_ERROR_BASE + 2;
const MOZILLA_PKIX_ERROR_V1_CERT_USED_AS_CA = MOZILLA_PKIX_ERROR_BASE + 3; const MOZILLA_PKIX_ERROR_V1_CERT_USED_AS_CA = MOZILLA_PKIX_ERROR_BASE + 3;
const MOZILLA_PKIX_ERROR_NOT_YET_VALID_CERTIFICATE = MOZILLA_PKIX_ERROR_BASE + 5; const MOZILLA_PKIX_ERROR_NOT_YET_VALID_CERTIFICATE = MOZILLA_PKIX_ERROR_BASE + 5;
const MOZILLA_PKIX_ERROR_NOT_YET_VALID_ISSUER_CERTIFICATE = MOZILLA_PKIX_ERROR_BASE + 6; const MOZILLA_PKIX_ERROR_NOT_YET_VALID_ISSUER_CERTIFICATE = MOZILLA_PKIX_ERROR_BASE + 6;
const MOZILLA_PKIX_ERROR_OCSP_RESPONSE_FOR_CERT_MISSING = MOZILLA_PKIX_ERROR_BASE + 8; const MOZILLA_PKIX_ERROR_OCSP_RESPONSE_FOR_CERT_MISSING = MOZILLA_PKIX_ERROR_BASE + 8;
const MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING = MOZILLA_PKIX_ERROR_BASE + 10; const MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING = MOZILLA_PKIX_ERROR_BASE + 10;
// Supported Certificate Usages // Supported Certificate Usages
const certificateUsageSSLClient = 0x0001; const certificateUsageSSLClient = 0x0001;
@ -196,7 +196,7 @@ function _getLibraryFunctionWithNoArguments(functionName, libraryName) {
let nsslib; let nsslib;
try { try {
nsslib = ctypes.open(path); nsslib = ctypes.open(path);
} catch(e) { } catch (e) {
// In case opening the library without a full path fails, // In case opening the library without a full path fails,
// try again with a full path. // try again with a full path.
let file = Services.dirsvc.get("GreBinD", Ci.nsILocalFile); let file = Services.dirsvc.get("GreBinD", Ci.nsILocalFile);
@ -482,12 +482,12 @@ function _setupTLSServerTest(serverBinName, certsPath)
// [ [typeOfResponse, certnick, extracertnick]...] // [ [typeOfResponse, certnick, extracertnick]...]
function generateOCSPResponses(ocspRespArray, nssDBlocation) function generateOCSPResponses(ocspRespArray, nssDBlocation)
{ {
let utilBinName = "GenerateOCSPResponse"; let utilBinName = "GenerateOCSPResponse";
let ocspGenBin = _getBinaryUtil(utilBinName); let ocspGenBin = _getBinaryUtil(utilBinName);
let retArray = new Array(); let retArray = [];
for (let i = 0; i < ocspRespArray.length; i++) { for (let i = 0; i < ocspRespArray.length; i++) {
let argArray = new Array(); let argArray = [];
let ocspFilepre = do_get_file(i.toString() + ".ocsp", true); let ocspFilepre = do_get_file(i.toString() + ".ocsp", true);
let filename = ocspFilepre.path; let filename = ocspFilepre.path;
// Using "sql:" causes the SQL DB to be used so we can run tests on Android. // Using "sql:" causes the SQL DB to be used so we can run tests on Android.

View File

@ -18,22 +18,22 @@ function check_telemetry() {
.getService(Ci.nsITelemetry) .getService(Ci.nsITelemetry)
.getHistogramById("SSL_CERT_ERROR_OVERRIDES") .getHistogramById("SSL_CERT_ERROR_OVERRIDES")
.snapshot(); .snapshot();
equal(histogram.counts[ 0], 0, "Should have 0 unclassified counts"); equal(histogram.counts[0], 0, "Should have 0 unclassified counts");
equal(histogram.counts[ 2], 8, equal(histogram.counts[2], 8,
"Actual and expected SEC_ERROR_UNKNOWN_ISSUER counts should match"); "Actual and expected SEC_ERROR_UNKNOWN_ISSUER counts should match");
equal(histogram.counts[ 3], 1, equal(histogram.counts[3], 1,
"Actual and expected SEC_ERROR_CA_CERT_INVALID counts should match"); "Actual and expected SEC_ERROR_CA_CERT_INVALID counts should match");
equal(histogram.counts[ 4], 0, equal(histogram.counts[4], 0,
"Actual and expected SEC_ERROR_UNTRUSTED_ISSUER counts should match"); "Actual and expected SEC_ERROR_UNTRUSTED_ISSUER counts should match");
equal(histogram.counts[ 5], 1, equal(histogram.counts[5], 1,
"Actual and expected SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE counts should match"); "Actual and expected SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE counts should match");
equal(histogram.counts[ 6], 0, equal(histogram.counts[6], 0,
"Actual and expected SEC_ERROR_UNTRUSTED_CERT counts should match"); "Actual and expected SEC_ERROR_UNTRUSTED_CERT counts should match");
equal(histogram.counts[ 7], 0, equal(histogram.counts[7], 0,
"Actual and expected SEC_ERROR_INADEQUATE_KEY_USAGE counts should match"); "Actual and expected SEC_ERROR_INADEQUATE_KEY_USAGE counts should match");
equal(histogram.counts[ 8], 2, equal(histogram.counts[8], 2,
"Actual and expected SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED counts should match"); "Actual and expected SEC_ERROR_CERT_SIGNATURE_ALGORITHM_DISABLED counts should match");
equal(histogram.counts[ 9], 10, equal(histogram.counts[9], 10,
"Actual and expected SSL_ERROR_BAD_CERT_DOMAIN counts should match"); "Actual and expected SSL_ERROR_BAD_CERT_DOMAIN counts should match");
equal(histogram.counts[10], 5, equal(histogram.counts[10], 5,
"Actual and expected SEC_ERROR_EXPIRED_CERTIFICATE counts should match"); "Actual and expected SEC_ERROR_EXPIRED_CERTIFICATE counts should match");

View File

@ -18,9 +18,9 @@ function excMessage(e) {
msg = msg + ": " + e.data; msg = msg + ": " + e.data;
} }
return msg; return msg;
} else {
return e.toString();
} }
return e.toString();
} }
function testGood(data) { function testGood(data) {

View File

@ -19,7 +19,7 @@ var certList = [
// I have to grab them by enumerating all the certs and then finding // I have to grab them by enumerating all the certs and then finding
// the ones that I am interested in. // the ones that I am interested in.
function get_ca_array() { function get_ca_array() {
let ret_array = new Array(); let ret_array = [];
let allCerts = certdb.getCerts(); let allCerts = certdb.getCerts();
let enumerator = allCerts.getEnumerator(); let enumerator = allCerts.getEnumerator();
while (enumerator.hasMoreElements()) { while (enumerator.hasMoreElements()) {

View File

@ -20,7 +20,7 @@ function certFromFile(cert_name) {
function loadCert(cert_name, trust_string) { function loadCert(cert_name, trust_string) {
let cert_filename = "test_pinning_dynamic/" + cert_name + ".pem"; let cert_filename = "test_pinning_dynamic/" + cert_name + ".pem";
addCertFromFile(certdb, cert_filename, trust_string); addCertFromFile(certdb, cert_filename, trust_string);
return constructCertFromFile(cert_filename); return constructCertFromFile(cert_filename);
} }

View File

@ -17,7 +17,7 @@ function certFromFile(cert_name) {
function loadCert(cert_name, trust_string) { function loadCert(cert_name, trust_string) {
let cert_filename = "test_pinning_dynamic/" + cert_name + ".pem"; let cert_filename = "test_pinning_dynamic/" + cert_name + ".pem";
addCertFromFile(certdb, cert_filename, trust_string); addCertFromFile(certdb, cert_filename, trust_string);
return constructCertFromFile(cert_filename); return constructCertFromFile(cert_filename);
} }

View File

@ -72,7 +72,7 @@ function tamper(inFilePath, outFilePath, modifications, newEntries) {
// Any leftover modification means that we were expecting to modify an entry // Any leftover modification means that we were expecting to modify an entry
// in the input file that wasn't there. // in the input file that wasn't there.
for(var name in modifications) { for (let name in modifications) {
if (modifications.hasOwnProperty(name)) { if (modifications.hasOwnProperty(name)) {
throw "input file was missing expected entries: " + name; throw "input file was missing expected entries: " + name;
} }

View File

@ -23,7 +23,7 @@ function prepare(tamper) {
if (tamper.copy) { if (tamper.copy) {
tamper.copy.forEach(i => { tamper.copy.forEach(i => {
let f = gTarget.clone(); let f = gTarget.clone();
i[0].split('/').forEach(seg => {f.append(seg);}); i[0].split("/").forEach(seg => { f.append(seg); });
f.copyTo(null, i[1]); f.copyTo(null, i[1]);
}); });
} }
@ -32,7 +32,7 @@ function prepare(tamper) {
if (tamper.delete) { if (tamper.delete) {
tamper.delete.forEach(i => { tamper.delete.forEach(i => {
let f = gTarget.clone(); let f = gTarget.clone();
i.split('/').forEach(seg => {f.append(seg);}); i.split("/").forEach(seg => { f.append(seg); });
f.remove(true); f.remove(true);
}); });
} }
@ -41,7 +41,7 @@ function prepare(tamper) {
if (tamper.corrupt) { if (tamper.corrupt) {
tamper.corrupt.forEach(i => { tamper.corrupt.forEach(i => {
let f = gTarget.clone(); let f = gTarget.clone();
i.split('/').forEach(seg => {f.append(seg);}); i.split("/").forEach(seg => { f.append(seg); });
let s = FileUtils.openFileOutputStream(f, FileUtils.MODE_WRONLY); let s = FileUtils.openFileOutputStream(f, FileUtils.MODE_WRONLY);
const str = "Kilroy was here"; const str = "Kilroy was here";
s.write(str, str.length); s.write(str, str.length);

View File

@ -238,7 +238,7 @@ function downloadAndParseChromeCerts(filename, certNameToSKD, certSKDToName) {
if (line.length == 0 || line[0] == '#') { if (line.length == 0 || line[0] == '#') {
continue; continue;
} }
switch(state) { switch (state) {
case PRE_NAME: case PRE_NAME:
chromeName = line; chromeName = line;
state = POST_NAME; state = POST_NAME;

View File

@ -8,6 +8,8 @@
// 3. run `[path to]/run-mozilla.sh [path to]/xpcshell \ // 3. run `[path to]/run-mozilla.sh [path to]/xpcshell \
// [path to]/getHSTSPreloadlist.js \ // [path to]/getHSTSPreloadlist.js \
// [absolute path to]/nsSTSPreloadlist.inc' // [absolute path to]/nsSTSPreloadlist.inc'
// Note: Running this file outputs a new nsSTSPreloadlist.inc in the current
// working directory.
var Cc = Components.classes; var Cc = Components.classes;
var Ci = Components.interfaces; var Ci = Components.interfaces;
@ -128,13 +130,10 @@ function processStsHeader(host, header, status, securityInfo) {
host.name + ": " + e + "\n"); host.name + ": " + e + "\n");
error = e; error = e;
} }
} } else if (status == 0) {
else { error = ERROR_CONNECTING_TO_HOST;
if (status == 0) { } else {
error = ERROR_CONNECTING_TO_HOST; error = ERROR_NO_HSTS_HEADER;
} else {
error = ERROR_NO_HSTS_HEADER;
}
} }
let forceInclude = (host.forceInclude || host.pins == "google"); let forceInclude = (host.forceInclude || host.pins == "google");
@ -204,7 +203,13 @@ function getHSTSStatus(host, resultList) {
} }
function compareHSTSStatus(a, b) { function compareHSTSStatus(a, b) {
return (a.name > b.name ? 1 : (a.name < b.name ? -1 : 0)); if (a.name > b.name) {
return 1;
}
if (a.name < b.name) {
return -1;
}
return 0;
} }
function writeTo(string, fos) { function writeTo(string, fos) {
@ -294,7 +299,7 @@ function getHSTSStatuses(inHosts, outStatuses) {
var expectedOutputLength = inHosts.length; var expectedOutputLength = inHosts.length;
var tmpOutput = []; var tmpOutput = [];
for (var i = 0; i < MAX_CONCURRENT_REQUESTS && inHosts.length > 0; i++) { for (var i = 0; i < MAX_CONCURRENT_REQUESTS && inHosts.length > 0; i++) {
var host = inHosts.shift(); let host = inHosts.shift();
dump("spinning off request to '" + host.name + "' (remaining retries: " + dump("spinning off request to '" + host.name + "' (remaining retries: " +
host.retries + ")\n"); host.retries + ")\n");
getHSTSStatus(host, tmpOutput); getHSTSStatus(host, tmpOutput);
@ -311,7 +316,7 @@ function getHSTSStatuses(inHosts, outStatuses) {
} }
if (inHosts.length > 0) { if (inHosts.length > 0) {
var host = inHosts.shift(); let host = inHosts.shift();
dump("spinning off request to '" + host.name + "' (remaining retries: " + dump("spinning off request to '" + host.name + "' (remaining retries: " +
host.retries + ")\n"); host.retries + ")\n");
getHSTSStatus(host, tmpOutput); getHSTSStatus(host, tmpOutput);