Skip to content

Commit

Permalink
Merge pull request #275 from skadefro/master
Browse files Browse the repository at this point in the history
up
  • Loading branch information
skadefro authored Aug 12, 2023
2 parents 0759da4 + 42a2ba5 commit 75b1f1c
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 58 deletions.
39 changes: 22 additions & 17 deletions OpenFlow/src/DatabaseConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2016,18 +2016,18 @@ export class DatabaseConnection extends events.EventEmitter {
Base.addRight(item, user._id, user.name, [Rights.full_control]);
}
item = this.ensureResource(item, collectionname);
// Logger.instanse.silly("Adding " + item._type + " " + name + " to database", span, { collection: collectionname, user: user.username });
// if (!DatabaseConnection.hasAuthorization(user, item, Rights.create)) { throw new Error("Access denied, no authorization to InsertOne " + item._type + " " + name + " to database"); }
} else if (DatabaseConnection.istimeseries(collectionname) && !DatabaseConnection.usemetadata(collectionname)) {

// } else if (DatabaseConnection.istimeseries(collectionname) && !DatabaseConnection.usemetadata(collectionname)) {
} else if (DatabaseConnection.istimeseries(collectionname)) {
if(NoderedUtil.IsNullEmpty(item[DatabaseConnection.timefield(collectionname)])) {
item[DatabaseConnection.timefield(collectionname)] = new Date(new Date().toISOString());
}
if (!DatabaseConnection.hasAuthorization(user, item, Rights.full_control)) {
Base.addRight(item, user._id, user.name, [Rights.full_control]);
item = this.ensureResource(item, collectionname);
if(DatabaseConnection.usemetadata(collectionname)) {
if (!DatabaseConnection.hasAuthorization(user, item, Rights.full_control)) {
Base.addRight(item, user._id, user.name, [Rights.full_control]);
item = this.ensureResource(item, collectionname);
}
}
} else {
} else { // fs.files ?
if(NoderedUtil.IsNullEmpty(item[DatabaseConnection.timefield(collectionname)])) {
item[DatabaseConnection.timefield(collectionname)] = new Date(new Date().toISOString());
}
Expand Down Expand Up @@ -2208,11 +2208,12 @@ export class DatabaseConnection extends events.EventEmitter {
}
} else if (DatabaseConnection.istimeseries(collectionname) && !DatabaseConnection.usemetadata(collectionname)) {
} else {
let metadata = DatabaseConnection.metadataname(collectionname);
item[metadata] = await this.CleanACL(item[metadata], user, collectionname, span);
if (item._type === "role" && collectionname === "users") {
item[metadata] = await this.Cleanmembers(item[metadata] as any, null, false, span);
}
// skip clean acl, to expensive
// let metadata = DatabaseConnection.metadataname(collectionname);
// item[metadata] = await this.CleanACL(item[metadata], user, collectionname, span);
// if (item._type === "role" && collectionname === "users") {
// item[metadata] = await this.Cleanmembers(item[metadata] as any, null, false, span);
// }
}


Expand Down Expand Up @@ -4324,10 +4325,14 @@ export class DatabaseConnection extends events.EventEmitter {
return true;
}
if(collectionname == "fullDocument._acl") return true;
if(Config.metadata_collections.indexOf(collectionname) > -1) {
const metadataname = DatabaseConnection.timeseries_collections_metadata[collectionname];
if(!NoderedUtil.IsNullEmpty(metadataname)) return true;
}
// old way
// if(Config.metadata_collections.indexOf(collectionname) > -1) {
// const metadataname = DatabaseConnection.timeseries_collections_metadata[collectionname];
// if(!NoderedUtil.IsNullEmpty(metadataname)) return true;
// }
const metadataname = DatabaseConnection.timeseries_collections_metadata[collectionname];
if(metadataname == "metadata") return true;
// if(!NoderedUtil.IsNullEmpty(metadataname)) return true;
return false;
}
static metadataname(collectionname: string) {
Expand Down
1 change: 1 addition & 0 deletions OpenFlow/src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export class Logger {
this.json(obj, span);
}
public verbose(message: string, span: Span, options?: any) {
if(!Config.log_verbose) return;
var s = Logger.getStackInfo(0);
if (s.method == "") s = Logger.getStackInfo(1);
if (s.method == "") s = Logger.getStackInfo(2);
Expand Down
7 changes: 6 additions & 1 deletion OpenFlow/src/WebServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,13 @@ export class WebServer {
});
this.app.use("/", express.static(path.join(__dirname, "/public")));
this.app.use(compression());
// this.app.use(express.urlencoded({ extended: true }));
// this.app.use(express.json());
// this.app.use(express.urlencoded({ extended: true, limit: '50mb', parameterLimit:50000 }));
// this.app.use(express.json({limit: '50mb'}));
this.app.use(express.urlencoded({ extended: true }));
this.app.use(express.json());
this.app.use(express.json({limit: '150mb'}));

this.app.use(cookieParser());
this.app.set('trust proxy', 1)
span?.addEvent("Add cookieSession");
Expand Down
2 changes: 1 addition & 1 deletion OpenFlow/src/dockerdriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class dockerdriver implements i_agent_driver {
"otel_trace_url=" + Config.otel_trace_url,
"otel_metric_url=" + Config.otel_metric_url,
"TZ=" + agent.tz,
"log_with_colors=false",
"log_with_colors=true",
"oidc_config=" + oidc_config,
"oidc_client_id=" + Config.agent_oidc_client_id,
"oidc_client_secret=" + Config.agent_oidc_client_secret,
Expand Down
2 changes: 1 addition & 1 deletion OpenFlow/src/public/Agent.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ <h2 class="card-title font-size-18 m-0">
<div class="px-card py-10 bg-light-lm bg-very-dark-dm rounded-bottom">
<!-- py-10 = padding-top: 1rem (10px) and padding-bottom: 1rem (10px), bg-light-lm = background-color: var(--gray-color-light) only in light mode, bg-very-dark-dm = background-color: var(--dark-color-dark) only in dark mode, rounded-bottom = rounded corners on the bottom -->
<p class="font-size-12 m-0"> <!-- font-size-12 = font-size: 1.2rem (12px), m-0 = margin: 0 -->
<pre>{{ ctrl.instancelog }}</pre>
<pre ng-bind-html="ctrl.instancelog"></pre>
</p>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions OpenFlow/src/public/Agents.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ <h1 translate lib="web">agents</h1>
<tr>
<th scope="col" ng-click="ctrl.ToggleOrder('name')"><strong translate lib="web">name</strong></th>
<th scope="col" ng-click="ctrl.ToggleOrder('image')"><strong translate lib="web">image</strong></th>
<th scope="col" ng-click="ctrl.ToggleOrder('os')"><strong translate lib="web">os</strong></th>
<th scope="col" ng-click="ctrl.ToggleOrder('arch')"><strong translate lib="web">arch</strong></th>
<th scope="col" ng-click="ctrl.ToggleOrder('_createdby')"><strong translate lib="web">createdby</strong></th>
<th scope="col" ng-click="ctrl.ToggleOrder('status')"><strong translate lib="web">status</strong></th>
<th class="text-right"></th>
Expand All @@ -44,6 +46,8 @@ <h1 translate lib="web">agents</h1>
<a ng-show="model.image == '' || model.image == null" ng-href="#/RunPackage/{{model._id}}">{{model.name | limitTo: 20}}</a>
</td>
<td>{{ctrl.trimimage(model.image)}}</td>
<td>{{model.os | limitTo: 20}}</td>
<td>{{model.arch | limitTo: 20}}</td>
<td>{{model._createdby | limitTo: 20}}</td>
<td>{{model.status | limitTo: 20}}</td>
<td class="text-right">
Expand Down
4 changes: 3 additions & 1 deletion OpenFlow/src/public/CommonControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,7 @@ export class entityCtrl<T> {
"$scope",
"$location",
"$routeParams",
"$sce",
"$interval",
"WebSocketClientService",
"api",
Expand All @@ -884,10 +885,11 @@ export class entityCtrl<T> {
public $scope: ng.IScope,
public $location: ng.ILocationService,
public $routeParams: ng.route.IRouteParamsService,
public $sce: ng.ISCEService,
public $interval: ng.IIntervalService,
public WebSocketClientService: WebSocketClientService,
public api: api,
public userdata: userdata
public userdata: userdata,
) {
this.id = $routeParams.id;
this.basequery = { _id: this.id };
Expand Down
Loading

0 comments on commit 75b1f1c

Please sign in to comment.