public/js/views/audit.js in conjur-asset-ui-1.3.0 vs public/js/views/audit.js in conjur-asset-ui-1.3.1
- old
+ new
@@ -4,11 +4,11 @@
(function(){
var ref$, em, strong, table, div, th, tr, td, thead, tbody, section, h3, time, map, each, unique, isType, join, compact_fields, extended_fields, FieldsMixin, AuditTableHeader, Timestamp, wrapArray, AuditEntry, newEventSet, AuditTable, GlobalAudit, urlOfRole, urlOfResource, AuditBox, out$ = typeof exports != 'undefined' && exports || this, slice$ = [].slice;
ref$ = React.DOM, em = ref$.em, strong = ref$.strong, table = ref$.table, div = ref$.div, th = ref$.th, tr = ref$.tr, td = ref$.td, thead = ref$.thead, tbody = ref$.tbody, section = ref$.section, h3 = ref$.h3, time = ref$.time;
ref$ = require('prelude-ls'), map = ref$.map, each = ref$.each, unique = ref$.unique, isType = ref$.isType, join = ref$.join;
compact_fields = ['auditview_user', 'auditview_action'];
- //extended_fields = ['timestamp', 'user', 'acting_as', 'action', 'entities', 'privilege','human'];
+ //extended_fields = ['timestamp', 'user', 'acting_as', 'action', 'entities', 'privilege','human'];
extended_fields = ['timestamp','auditview_user','auditview_action'];
known_rolsource_types = [ 'user','group','host','layer','policy']; // what if somebody explicitly will create the role of such type?
FieldsMixin = {
fields: function(){
if (this.props.compact) {
@@ -57,10 +57,13 @@
// TODO: make message a separate React Class
humanizeEvent: function(e) {
// copy of SHORT_FORMATS logic from cli-ruby:lib/conjur/command/audit.rb
var msg="";
+ var ResourceLink = conjur.views.ResourceLink;
+ var RoleLink = conjur.views.RoleLink;
+
if ((e.kind=='resource') && (e.action=='check')) {
msg = [ ]
if ( e.allowed ) {
msg.push("performed ");
msg.push(em({}, e.privilege));
@@ -82,11 +85,11 @@
} else if ((e.kind=="resource") && (e.action=="destroy")) {
msg = [ " deleted ", ResourceLink({id: e.resource, noIcon: true}) ];
} else if ((e.kind=="resource") && (e.action=="permit")) {
msg = [ " permitted ", RoleLink({id: e.grantee, noIcon: true}), " to ", em({}, e.privilege), " ", ResourceLink({id: e.resource, noIcon: true}) ]
if ( e.grant_option )
- msg.push(" with grant option");
+ msg.push(" with grant option");
} else if ((e.kind=="resource") && (e.action=="deny")) {
msg = [ " denied ", em({}, e.privilege), " from ", RoleLink({id: e.grantee, noIcon: true}), " on ", ResourceLink({id: e.resource, noIcon: true}) ];
} else if ((e.kind=="resource") && (e.action=="permitted_roles")) {
msg = [ " listed roles permitted to ", em({}, e.privilege), " on ", ResourceLink({id: e.resource, noIcon: true}) ];
} else if ((e.kind=="role") && (e.action=="check")) {
@@ -124,36 +127,39 @@
} else if (e.kind=="audit") {
var action_part = _.compact([e.facility, e.action]).join(":");
var parts = [action_part];
if (e.role!=null) {
parts.push(" by ");
- parts.push(RoleLink({id: e.role, noIcon: true}));
+ parts.push(RoleLink({id: e.role, noIcon: true}));
}
- if (e.resource_id!=null) {
+ if (e.resource_id!=null) {
parts.push(" on");
- parts.push(ResourceLink({id: e.resource_id, noIcon: true}));
+ parts.push(ResourceLink({id: e.resource_id, noIcon: true}));
}
- if (e.allowed!=null) {
- parts.push(" (allowed: "+e.allowed+")");
+ if (e.allowed!=null) {
+ parts.push(" (allowed: "+e.allowed+")");
}
var statement = parts.join(" ");
msg = [" reported ", parts ];
- if (e.audit_message!=null) {
+ if (e.audit_message!=null) {
msg.push("; message: ");
msg.push(e.audit_message);
}
} else {
msg+=" unknown event: "+e.kind+":"+e.action+"!";
- }
+ }
if (e.error!=null) {
msg+=" (failed with "+e.error+")";
}
return msg;
},
transformField: function(key, value){
+ var ResourceLink = conjur.views.ResourceLink;
+ var RoleLink = conjur.views.RoleLink;
+
var that;
switch (key) {
case 'entities':
return [
(that = this.props.resource) != null ? ResourceLink({
@@ -177,11 +183,11 @@
});
}
break;
case 'auditview_user': //virtual field
var acting_user =this.props.user;
- var acting_role = this.props.acting_as;
+ var acting_role = this.props.acting_as;
msg = [ RoleLink({id: acting_user}) ];
if ((acting_role!=null) && (acting_role != acting_user)) {
msg.push([" as ", RoleLink({id: acting_role})]);
}
return msg;
@@ -190,11 +196,11 @@
return Timestamp({
time: value
});
}
break;
- case 'auditview_action':
+ case 'auditview_action':
return this.humanizeEvent(this.props);
default:
return value;
}
},
@@ -231,11 +237,11 @@
getInitialState: function(){
return {
events: newEventSet()
};
},
- knownRolsourceTypes: function() {
+ knownRolsourceTypes: function() {
return ;
},
render: function(){
var compact;
compact = this.props.compact;
@@ -248,11 +254,11 @@
AuditTableHeader({
key: 'thead',
compact: compact
}), tbody({
key: 'tbody'
- }, this.state.events.filter(function(ev){
+ }, this.state.events.filter(function(ev){
// remove internal resources creation
if ((ev.role!=null) && (ev.role.split(':')[1] == '@')) {
return false;
}
if ((ev.resource!=null) && (ev.resource.split(':')[1] == '@')) {
@@ -268,16 +274,16 @@
// hide automated creation of roles corresponding to resources of known type
if ((ev.kind=="role") && (ev.action=="create")) {
var rolekind = ev.role.split(':')[1];
if (_.contains(known_rolsource_types, rolekind)) {
return false;
- }
- }
+ }
+ }
return true;
}).map(function(it){
// new way to clone objects, custom clone$ does not work no more as expected
- var ref$ = React.addons.update(it, {$merge: {key: it.id, compact: compact} });
+ var ref$ = React.addons.update(it, {$merge: {key: it.id, compact: compact} });
return new AuditEntry(ref$);
}))
])
]);
},
@@ -343,10 +349,10 @@
roles);
resSrcs = map(urlOfResource)(
resources);
things = join(', ')(
unique(
- roles.concat(resources)));
+ roles.concat(resources)));
var options= { src: roleSrcs.concat(resSrcs) };
if (this.props.tabview==null) {
options=_.extend(options, {caption: "Recent Activity"});
}