-
Couldn't load subscription status.
- Fork 231
Additional checks for security concerns during Import YAML and Template process #1321
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| 'use strict'; | ||
|
|
||
| angular.module("openshiftConsole") | ||
| .factory("SecurityCheckService", function(APIService, $filter, Constants) { | ||
| var humanizeKind = $filter('humanizeKind'); | ||
| var getSecurityAlerts = function(resources, project) { | ||
| var alerts = []; | ||
| var clusterScopedResources = []; | ||
| var roleBindingResources = []; | ||
| var roleResources = []; | ||
| var notWhitelistedResources = []; | ||
| _.each(resources, function(resource) { | ||
| if (!_.get(resource, "kind")) { | ||
| // This isn't a valid API object | ||
| return; | ||
| } | ||
| var rgv = APIService.objectToResourceGroupVersion(resource); | ||
| var apiInfo = APIService.apiInfo(rgv); | ||
| if (!apiInfo.namespaced) { | ||
| clusterScopedResources.push(resource); | ||
| } | ||
| else if (rgv.resource === "rolebindings" && (rgv.group === '' || rgv.group === "rbac.authorization.k8s.io")) { | ||
| // If role in the rolebinding is one of the "safe" ones ignore it (view or image puller), otherwise warn | ||
| var roleRef = _.get(resource, 'roleRef.name'); | ||
| if (roleRef !== 'view' && roleRef !== 'system:image-puller') { | ||
| roleBindingResources.push(resource); | ||
| } | ||
| } | ||
| else if (rgv.resource === "roles" && (rgv.group === '' || rgv.group === "rbac.authorization.k8s.io")) { | ||
| roleResources.push(resource); | ||
| } | ||
| else if (!_.find(Constants.SECURITY_CHECK_WHITELIST, {resource: rgv.resource, group: rgv.group})) { | ||
| notWhitelistedResources.push(resource); | ||
| } | ||
| }); | ||
| if (clusterScopedResources.length) { | ||
| var clusterStrs = _.uniq(_.map(clusterScopedResources, function(resource) { | ||
| return humanizeKind(resource.kind); | ||
| })); | ||
| alerts.push({ | ||
| type: 'warning', | ||
| message: "This will create resources outside of the project, which might impact all users of the cluster.", | ||
| details: "Typically only cluster administrators can create these resources. The cluster-level resources being created are: " + clusterStrs.join(", ") | ||
| }); | ||
| } | ||
| if (roleBindingResources.length) { | ||
| var roleBindingStrs = []; | ||
| _.each(roleBindingResources, function(resource){ | ||
| _.each(resource.subjects, function(subject) { | ||
| var str = humanizeKind(subject.kind) + " "; | ||
| if (subject.kind === 'ServiceAccount') { | ||
| str += (subject.namespace || project) + "/"; | ||
| } | ||
| str += subject.name; | ||
| roleBindingStrs.push(str); | ||
| }); | ||
| }); | ||
| roleBindingStrs = _.uniq(roleBindingStrs); | ||
| alerts.push({ | ||
| type: 'warning', | ||
| message: "This will grant permissions to your project.", | ||
| details: "Permissions are being granted to: " + roleBindingStrs.join(", ") | ||
| }); | ||
| } | ||
| if (roleResources.length) { | ||
| alerts.push({ | ||
| type: 'info', | ||
| message: "This will create additional membership roles within the project.", | ||
| details: "Admins will be able to grant these custom roles to users, groups, and service accounts." | ||
| }); | ||
| } | ||
| if (notWhitelistedResources.length) { | ||
| var notWhitelistStrs = _.uniq(_.map(notWhitelistedResources, function(resource) { | ||
| return humanizeKind(resource.kind); | ||
| })); | ||
| alerts.push({ | ||
| type: 'warning', | ||
| message: "This will create resources that may have security or project behavior implications.", | ||
| details: "Make sure you understand what they do before creating them. The resources being created are: " + notWhitelistStrs.join(", ") | ||
| }); | ||
| } | ||
| return alerts; | ||
| }; | ||
|
|
||
| return { | ||
| // Gets security alerts relevant to a set of resources | ||
| // Returns: Array of alerts | ||
| getSecurityAlerts: getSecurityAlerts | ||
| }; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to bump this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, won't be able to create cluster resources without this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right of course :)