forked from mirrors/gecko-dev
Bug 1786197 - Turn on ESLint rule for prefer-boolean-length-check for security. r=keeler
Differential Revision: https://phabricator.services.mozilla.com/D155165
This commit is contained in:
parent
145c8af411
commit
e3bad2d44a
12 changed files with 27 additions and 29 deletions
|
|
@ -490,7 +490,6 @@ module.exports = {
|
||||||
"modules/**",
|
"modules/**",
|
||||||
"netwerk/**",
|
"netwerk/**",
|
||||||
"remote/**",
|
"remote/**",
|
||||||
"security/manager/**",
|
|
||||||
"storage/test/unit/test_vacuum.js",
|
"storage/test/unit/test_vacuum.js",
|
||||||
"taskcluster/docker/periodic-updates/scripts/**",
|
"taskcluster/docker/periodic-updates/scripts/**",
|
||||||
"testing/**",
|
"testing/**",
|
||||||
|
|
|
||||||
|
|
@ -700,7 +700,7 @@ async function restoreCerts() {
|
||||||
errorCode = certdb.importPKCS12File(fp.file, password.value);
|
errorCode = certdb.importPKCS12File(fp.file, password.value);
|
||||||
if (
|
if (
|
||||||
errorCode == Ci.nsIX509CertDB.ERROR_BAD_PASSWORD &&
|
errorCode == Ci.nsIX509CertDB.ERROR_BAD_PASSWORD &&
|
||||||
password.value.length == 0
|
!password.value.length
|
||||||
) {
|
) {
|
||||||
// It didn't like empty string password, try no password.
|
// It didn't like empty string password, try no password.
|
||||||
errorCode = certdb.importPKCS12File(fp.file, null);
|
errorCode = certdb.importPKCS12File(fp.file, null);
|
||||||
|
|
|
||||||
|
|
@ -155,13 +155,13 @@ async function setDetails() {
|
||||||
];
|
];
|
||||||
let parsedCert = await parse(pemToDER(cert.getBase64DERString()));
|
let parsedCert = await parse(pemToDER(cert.getBase64DERString()));
|
||||||
let keyUsages = parsedCert.ext.keyUsages;
|
let keyUsages = parsedCert.ext.keyUsages;
|
||||||
if (keyUsages && keyUsages.purposes.length > 0) {
|
if (keyUsages && keyUsages.purposes.length) {
|
||||||
detailLines.push(
|
detailLines.push(
|
||||||
bundle.getFormattedString("clientAuthKeyUsages", [keyUsages.purposes])
|
bundle.getFormattedString("clientAuthKeyUsages", [keyUsages.purposes])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let emailAddresses = cert.getEmailAddresses();
|
let emailAddresses = cert.getEmailAddresses();
|
||||||
if (emailAddresses.length > 0) {
|
if (emailAddresses.length) {
|
||||||
let joinedAddresses = emailAddresses.join(", ");
|
let joinedAddresses = emailAddresses.join(", ");
|
||||||
detailLines.push(
|
detailLines.push(
|
||||||
bundle.getFormattedString("clientAuthEmailAddresses", [joinedAddresses])
|
bundle.getFormattedString("clientAuthEmailAddresses", [joinedAddresses])
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ function onLoad() {
|
||||||
|
|
||||||
let bundle = document.getElementById("pippki_bundle");
|
let bundle = document.getElementById("pippki_bundle");
|
||||||
let caName = gCert.commonName;
|
let caName = gCert.commonName;
|
||||||
if (caName.length == 0) {
|
if (!caName.length) {
|
||||||
caName = bundle.getString("unnamedCA");
|
caName = bundle.getString("unnamedCA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -332,7 +332,7 @@ class IntermediatePreloads {
|
||||||
lazy.log.debug(
|
lazy.log.debug(
|
||||||
`There are ${waiting.length} intermediates awaiting download.`
|
`There are ${waiting.length} intermediates awaiting download.`
|
||||||
);
|
);
|
||||||
if (waiting.length == 0) {
|
if (!waiting.length) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
Services.obs.notifyObservers(
|
Services.obs.notifyObservers(
|
||||||
null,
|
null,
|
||||||
|
|
@ -605,7 +605,7 @@ class CRLiteFilters {
|
||||||
let fullFiltersDownloaded = filtersDownloaded.filter(
|
let fullFiltersDownloaded = filtersDownloaded.filter(
|
||||||
filter => !filter.incremental
|
filter => !filter.incremental
|
||||||
);
|
);
|
||||||
if (fullFiltersDownloaded.length > 0) {
|
if (fullFiltersDownloaded.length) {
|
||||||
if (fullFiltersDownloaded.length > 1) {
|
if (fullFiltersDownloaded.length > 1) {
|
||||||
lazy.log.warn("trying to install more than one full CRLite filter?");
|
lazy.log.warn("trying to install more than one full CRLite filter?");
|
||||||
}
|
}
|
||||||
|
|
@ -643,7 +643,7 @@ class CRLiteFilters {
|
||||||
concatenatedStashes.set(filter.bytes, offset);
|
concatenatedStashes.set(filter.bytes, offset);
|
||||||
offset += filter.bytes.length;
|
offset += filter.bytes.length;
|
||||||
}
|
}
|
||||||
if (concatenatedStashes.length > 0) {
|
if (concatenatedStashes.length) {
|
||||||
lazy.log.debug(
|
lazy.log.debug(
|
||||||
`adding concatenated incremental updates of total length ${concatenatedStashes.length}`
|
`adding concatenated incremental updates of total length ${concatenatedStashes.length}`
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class OID {
|
||||||
bytes.shift();
|
bytes.shift();
|
||||||
let accumulator = 0;
|
let accumulator = 0;
|
||||||
// Lint TODO: prevent overflow here
|
// Lint TODO: prevent overflow here
|
||||||
while (bytes.length > 0) {
|
while (bytes.length) {
|
||||||
let value = bytes.shift();
|
let value = bytes.shift();
|
||||||
accumulator *= 128;
|
accumulator *= 128;
|
||||||
if (value > 128) {
|
if (value > 128) {
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ async function checkServerCertificates(win, expectedValues = []) {
|
||||||
|
|
||||||
// The strings we will get from the DOM are localized with Fluent.
|
// The strings we will get from the DOM are localized with Fluent.
|
||||||
// This will wait until the translation is applied.
|
// This will wait until the translation is applied.
|
||||||
if (expectedValues.length > 0) {
|
if (expectedValues.length) {
|
||||||
await BrowserTestUtils.waitForCondition(
|
await BrowserTestUtils.waitForCondition(
|
||||||
() => labels[1].value || labels[1].textContent.length > 0,
|
() => labels[1].value || !!labels[1].textContent.length,
|
||||||
"At least one label is populated"
|
"At least one label is populated"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ add_task(async function testRememberedDecisionsUI() {
|
||||||
);
|
);
|
||||||
|
|
||||||
await BrowserTestUtils.waitForCondition(
|
await BrowserTestUtils.waitForCondition(
|
||||||
() => labels[10].textContent.length > 0,
|
() => !!labels[10].textContent.length,
|
||||||
"Localized label is populated"
|
"Localized label is populated"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,7 @@ function asyncTestEV(
|
||||||
) {
|
) {
|
||||||
let now = Date.now() / 1000;
|
let now = Date.now() / 1000;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let ocspResponder =
|
let ocspResponder = expectedOCSPRequestPaths.length
|
||||||
expectedOCSPRequestPaths.length > 0
|
|
||||||
? startOCSPResponder(
|
? startOCSPResponder(
|
||||||
SERVER_PORT,
|
SERVER_PORT,
|
||||||
"www.example.com",
|
"www.example.com",
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ function doHash(algo, value, cmp) {
|
||||||
|
|
||||||
function doHashStream(algo, value, cmp) {
|
function doHashStream(algo, value, cmp) {
|
||||||
// TODO(Bug 459835): Make updateFromStream() accept zero length streams.
|
// TODO(Bug 459835): Make updateFromStream() accept zero length streams.
|
||||||
if (value.length == 0) {
|
if (!value.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,7 +337,7 @@ add_task(async function test_preload_basic() {
|
||||||
|
|
||||||
let localDB = await IntermediatePreloadsClient.client.db;
|
let localDB = await IntermediatePreloadsClient.client.db;
|
||||||
let data = await localDB.list();
|
let data = await localDB.list();
|
||||||
ok(data.length > 0, "should have some entries");
|
ok(!!data.length, "should have some entries");
|
||||||
// simulate a sync (syncAndDownload doesn't actually... sync.)
|
// simulate a sync (syncAndDownload doesn't actually... sync.)
|
||||||
await IntermediatePreloadsClient.client.emit("sync", {
|
await IntermediatePreloadsClient.client.emit("sync", {
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -402,7 +402,7 @@ add_task(async function test_delete() {
|
||||||
|
|
||||||
let localDB = await IntermediatePreloadsClient.client.db;
|
let localDB = await IntermediatePreloadsClient.client.db;
|
||||||
let data = await localDB.list();
|
let data = await localDB.list();
|
||||||
ok(data.length > 0, "should have some entries");
|
ok(!!data.length, "should have some entries");
|
||||||
let subject = data[0].subjectDN;
|
let subject = data[0].subjectDN;
|
||||||
let certStorage = Cc["@mozilla.org/security/certstorage;1"].getService(
|
let certStorage = Cc["@mozilla.org/security/certstorage;1"].getService(
|
||||||
Ci.nsICertStorage
|
Ci.nsICertStorage
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,7 @@ add_task(async function() {
|
||||||
);
|
);
|
||||||
let recoveryPhrase = await keystore.asyncGenerateSecret(LABELS[0]);
|
let recoveryPhrase = await keystore.asyncGenerateSecret(LABELS[0]);
|
||||||
ok(
|
ok(
|
||||||
recoveryPhrase && recoveryPhrase.length > 0,
|
recoveryPhrase && !!recoveryPhrase.length,
|
||||||
"we should be able to re-use that label to generate a new secret"
|
"we should be able to re-use that label to generate a new secret"
|
||||||
);
|
);
|
||||||
await delete_all_secrets();
|
await delete_all_secrets();
|
||||||
|
|
@ -401,7 +401,7 @@ add_task(async function() {
|
||||||
|
|
||||||
let recoveryPhrase = await keystore.asyncGenerateSecret(LABELS[0]);
|
let recoveryPhrase = await keystore.asyncGenerateSecret(LABELS[0]);
|
||||||
ok(
|
ok(
|
||||||
recoveryPhrase && recoveryPhrase.length > 0,
|
recoveryPhrase && !!recoveryPhrase.length,
|
||||||
"we should be able to use that label to generate a new secret"
|
"we should be able to use that label to generate a new secret"
|
||||||
);
|
);
|
||||||
ok(
|
ok(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue