selinux: Apply strict equality everywhere

This commit is contained in:
Jelle van der Waa 2026-10-28 18:19:45 +01:00 committed by Jelle van der Waa
parent 12dc5d5578
commit 5ea7b33c00
4 changed files with 18 additions and 18 deletions

View file

@ -66,15 +66,15 @@ export function init(statusChangedCallback) {
return;
const key = items[0].trim();
const value = items[1].trim();
if (key == "SELinux status") {
status.enabled = (value == "enabled");
} else if (key == "Current mode") {
status.enforcing = (value == "enforcing");
} else if (key == "Mode from config file") {
if (value == 'error (Permission denied)') {
if (key === "SELinux status") {
status.enabled = (value === "enabled");
} else if (key === "Current mode") {
status.enforcing = (value === "enforcing");
} else if (key === "Mode from config file") {
if (value === 'error (Permission denied)') {
status.configEnforcing = undefined;
} else {
status.configEnforcing = (value == "enforcing");
status.configEnforcing = (value === "enforcing");
}
}
});
@ -177,7 +177,7 @@ export function getModifications(statusChangedCallback) {
const items = mod.split(" ");
// Skip enumeration of types, e.g. 'boolean -D'
if (items.length === 2 && items[1] == "-D")
if (items.length === 2 && items[1] === "-D")
return result;
if (manageditems.indexOf(items[0]) < 0) {

View file

@ -69,7 +69,7 @@ const initStore = function(rootElement) {
const runFix = function(alertId, analysisId, fixId, runCommand) {
let idx;
for (idx = dataStore.entries.length - 1; idx >= 0; --idx) {
if (dataStore.entries[idx].key == alertId)
if (dataStore.entries[idx].key === alertId)
break;
}
if (idx < 0) {
@ -119,7 +119,7 @@ const initStore = function(rootElement) {
.then(() => {
let idx;
for (idx = dataStore.entries.length - 1; idx >= 0; --idx) {
if (dataStore.entries[idx].key == alertId)
if (dataStore.entries[idx].key === alertId)
break;
}
if (idx < 0)
@ -168,7 +168,7 @@ const initStore = function(rootElement) {
// we start at the back because that's where we push new entries
// if we receive an alert multiple times, this is where it will be
for (let idx = dataStore.entries.length - 1; idx >= 0; --idx) {
if (dataStore.entries[idx].key == localId) {
if (dataStore.entries[idx].key === localId) {
if (description === undefined || count === undefined) {
dataStore.entries[idx].details = details;
return;
@ -199,7 +199,7 @@ const initStore = function(rootElement) {
*/
const handleMultipleMessages = function(entries) {
const detailPromises = [];
for (let idxEntry = 0; idxEntry != entries.length; ++idxEntry) {
for (let idxEntry = 0; idxEntry !== entries.length; ++idxEntry) {
const entry = entries[idxEntry];
maybeUpdateAlert(entry.localId, entry.summary, entry.reportCount, undefined);
detailPromises.push(dataStore.getAlertDetails(entry.localId));

View file

@ -39,7 +39,7 @@ client.init = function() {
client.alertCallback = null;
function handleSignal(event, name, args) {
if (client.alertCallback && name == "alert") {
if (client.alertCallback && name === "alert") {
const level = args[0];
const localId = args[1];
client.alertCallback(level, localId);

View file

@ -65,7 +65,7 @@ class SELinuxEventDetails extends React.Component {
}
if (fixable) {
if ((itm.fix) && (itm.fix.plugin == itm.analysisId)) {
if ((itm.fix) && (itm.fix.plugin === itm.analysisId)) {
if (itm.fix.running) {
msg = (
<div>
@ -127,7 +127,7 @@ class SELinuxEventDetails extends React.Component {
const lines = itm.doText.split("\n");
let lastCommand = false;
lines.forEach(l => {
if (l[0] == "#") { // command
if (l[0] === "#") { // command
if (lastCommand) // When appending command remove "# ". Only the first command keeps it and it is removed later on
parts[parts.length - 1] += ("\n" + l.substring(2));
else
@ -138,7 +138,7 @@ class SELinuxEventDetails extends React.Component {
lastCommand = false;
}
});
doElement = parts.map((p, index) => p[0] == "#"
doElement = parts.map((p, index) => p[0] === "#"
? codeBlock(p.substring(2), index)
: <span key={p}>{p}</span>);
}
@ -160,7 +160,7 @@ class SELinuxEventDetails extends React.Component {
</div>
{fixit}
</div>
{itmIdx != self.props.details.pluginAnalysis.length - 1 && <Divider />}
{itmIdx !== self.props.details.pluginAnalysis.length - 1 && <Divider />}
</StackItem>
);
});
@ -353,7 +353,7 @@ export class SETroubleshootPage extends React.Component {
},
];
// if the alert has level "red", it's critical
const criticalAlert = (itm.details && 'level' in itm.details && itm.details.level == "red")
const criticalAlert = (itm.details && 'level' in itm.details && itm.details.level === "red")
? <ExclamationTriangleIcon className="ct-icon-exclamation-triangle pf-v6-c-icon pf-m-lg" />
: null;
const columns = [