Skip to content

Commit

Permalink
feat: adding a msg for reachability permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
ssmirr committed Feb 12, 2020
1 parent 8c78bdd commit 2c90f58
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions lib/inspect/checks/reachable.js
Expand Up @@ -35,15 +35,17 @@ class reachableCheck extends Check {
resource: path,
status: true,
expected: fileExists.expected,
actual: permission ? fileExists.actual : undefined
actual: permission ? fileExists.actual : undefined,
msg: fileExists.msg
});
}
} else {
results.push({
resource: path,
status: false,
expected: fileExists.expected,
actual: permission ? fileExists.actual : undefined
actual: permission ? fileExists.actual : undefined,
msg: fileExists.msg
});
}
}
Expand All @@ -54,7 +56,8 @@ class reachableCheck extends Check {
results.forEach((result) => {
let message = chalk`{gray [${result.resource}]} {white status:} {gray ${result.status}} ` +
(result.expected ? chalk`{white expected permission:} {gray ${result.expected}} ` : '') +
(result.actual ? chalk`{white actual permission:} {gray ${result.actual}}` : '');
(result.actual ? chalk`{white actual permission:} {gray ${result.actual}} ` : '') +
(result.msg ? chalk`{white msg:} {gray ${result.msg}}` : '');

this.reporter.report(message, result.status === true);
});
Expand All @@ -79,6 +82,7 @@ class reachableCheck extends Check {
let status = fileExists;
let actual = '';
let expected = ''
let msg;

if (fileExists) {

Expand Down Expand Up @@ -112,12 +116,16 @@ class reachableCheck extends Check {
let usersGroups = (await this.connector.exec(`groups ${user}`)).stdout.split(':')[1].trim().split(' ');

// if user is in the group of file/dir
if (usersGroups.includes(actualGroup))
if (usersGroups.includes(actualGroup)){
status = status && actualGroupPermission.includes(p);
msg = `${user} is in ${actualGroup} group`;
}

// if user is NOT in the group of file/dir
else
else{
status = status && actualOtherPermission.includes(p);
if(!status) msg = `${user} is NOT in ${actualGroup} group`;
}
}

}
Expand Down Expand Up @@ -154,7 +162,8 @@ class reachableCheck extends Check {
return {
status,
expected: expected,
actual: actual + (isWin ? ', user is currently not supported on Windows':'')
actual: actual + (isWin ? ', user is currently not supported on Windows':''),
msg
}
}

Expand Down

0 comments on commit 2c90f58

Please sign in to comment.