Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selinux: Fix error reporting #18670

Merged
merged 1 commit into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 42 additions & 55 deletions pkg/selinux/setroubleshoot-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,69 +107,56 @@ client.init = function(capabilitiesChangedCallback) {
lastSeen: when the alert was seen for the last time, timestamp in ms
level: "green", "yellow" or "red"
*/
client.getAlert = function(localId) {
return new Promise((resolve, reject) => {
client.proxy.call("get_alert", [localId])
.then(result => {
const details = {
localId: result[0],
summary: result[1],
reportCount: result[2],
auditEvent: result[3],
pluginAnalysis: result[4],
firstSeen: result[5] / 1000,
lastSeen: result[6] / 1000,
level: result[7],
};
// cleanup analysis
details.pluginAnalysis = details.pluginAnalysis.map(itm => ({
ifText: itm[0],
thenText: itm[1],
doText: itm[2],
analysisId: itm[3],
fixable: itm[4],
reportBug: itm[5],
}));
resolve(details);
})
.catch(ex => {
console.warn("Unable to get alert for id " + localId);
console.warn(ex);
reject(new Error(cockpit.format(_("Unable to get alert: $0"), localId)));
});
});
};
client.getAlert = localId => client.proxy.call("get_alert", [localId])
.then(result => {
const details = {
localId: result[0],
summary: result[1],
reportCount: result[2],
auditEvent: result[3],
pluginAnalysis: result[4],
firstSeen: result[5] / 1000,
lastSeen: result[6] / 1000,
level: result[7],
};
// cleanup analysis
details.pluginAnalysis = details.pluginAnalysis.map(itm => ({
ifText: itm[0],
thenText: itm[1],
doText: itm[2],
analysisId: itm[3],
fixable: itm[4],
reportBug: itm[5],
}));
return details;
})
.catch(ex => {
console.warn("Unable to get alert for id", localId, ":", JSON.stringify(ex));
return Promise.reject(new Error(`Unable to get alert for id ${localId}: ${ex.toString()}`));
Comment on lines +133 to +135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 added lines are not executed by any test. Details

});

/* Run a fix via SetroubleshootFixit
The analysisId is given as part of pluginAnalysis entries in alert details
*/
client.runFix = function(alertId, analysisId) {
return new Promise((resolve, reject) => {
client.proxyFixit.call("run_fix", [alertId, analysisId])
.then(result => resolve(result[0]))
.catch(ex => reject(new Error(cockpit.format(_("Unable to run fix: $0"), ex))));
});
};
client.runFix = (alertId, analysisId) => client.proxyFixit.call("run_fix", [alertId, analysisId])
.then(result => result[0])
.catch(ex => {
console.warn("Unable to run fix:", JSON.stringify(ex));
return Promise.reject(new Error(cockpit.format(_("Unable to run fix: $0"), ex.toString())));
Comment on lines +143 to +145
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 added lines are not executed by any test. Details

});

/* Delete an alert from the database (will be removed for all users), returns true on success
* Only assign this to the client variable if the dbus interface actually supports the operation
*/
const deleteAlert = function(localId) {
return new Promise((resolve, reject) => {
client.proxy.call("delete_alert", [localId])
.then(success => {
if (success)
resolve();
else
reject(new Error(cockpit.format(_("Failed to delete alert: $0"), localId)));
})
.catch(ex => {
console.warn("Unable to delete alert with id " + localId);
console.warn(ex);
reject(new Error(cockpit.format(_("Error while deleting alert: $0"), localId)));
});
});
};
const deleteAlert = localId => client.proxy.call("delete_alert", [localId])
.then(success => {
if (!success)
return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), localId)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This added line is not executed by any test. Details

})
.catch(ex => {
console.warn("Unable to delete alert with id", localId, ":", JSON.stringify(ex));
return Promise.reject(new Error(cockpit.format(_("Failed to delete alert: $0"), ex.toString())));
Comment on lines +156 to +158
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 3 added lines are not executed by any test. Details

});

// earlier versions of the dbus interface don't support alert deletion/dismissal
// HACK https://bugzilla.redhat.com/show_bug.cgi?id=1306700
Expand Down