greybel-mock-environment 1.1.7 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/environment.d.ts +1 -1
- package/dist/environment.js +22 -18
- package/dist/fs.d.ts +28 -3
- package/dist/fs.js +268 -174
- package/dist/generators/network.d.ts +3 -1
- package/dist/generators/network.js +39 -7
- package/dist/types/computer.d.ts +4 -0
- package/dist/types/computer.js +10 -0
- package/dist/types/device.d.ts +10 -1
- package/dist/types/device.js +87 -1
- package/dist/types/file-system.d.ts +16 -10
- package/dist/types/file-system.js +19 -14
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.js +5 -4
- package/dist/types/library.d.ts +17 -0
- package/dist/types/library.js +21 -0
- package/dist/types/router.d.ts +6 -0
- package/dist/types/router.js +60 -0
- package/dist/types/session.d.ts +5 -3
- package/dist/types/session.js +2 -1
- package/dist/types/switch.d.ts +4 -0
- package/dist/types/switch.js +7 -0
- package/dist/types/version.d.ts +12 -0
- package/dist/types/version.js +84 -0
- package/dist/types/vulnerabilities.d.ts +1 -19
- package/dist/types/vulnerabilities.js +1 -39
- package/dist/utils.d.ts +4 -1
- package/dist/utils.js +22 -1
- package/package.json +1 -1
package/dist/environment.d.ts
CHANGED
|
@@ -26,12 +26,12 @@ export default class MockEnvironment {
|
|
|
26
26
|
computer: Computer;
|
|
27
27
|
} | null;
|
|
28
28
|
setupLibraries(): void;
|
|
29
|
+
setupLocalSession(username: string, password: string): void;
|
|
29
30
|
getLatestSession(): Session;
|
|
30
31
|
getLocal(): Session;
|
|
31
32
|
connectLocal(router: Router): void;
|
|
32
33
|
getRouterByIp(ipAddress: string): Router | null;
|
|
33
34
|
getSwitchByIp(ipAddress: string): Switch | null;
|
|
34
|
-
getComputersOfRouterByIp(ipAddress: string): Computer[];
|
|
35
35
|
findRouterViaNS(name: string): Router;
|
|
36
36
|
getEmailViaLogin(email: string, password: string): EMail | null;
|
|
37
37
|
getEmail(email: string): EMail | null;
|
package/dist/environment.js
CHANGED
|
@@ -63,15 +63,7 @@ var MockEnvironment = /** @class */ (function () {
|
|
|
63
63
|
emailGenerator: me.emailGenerator
|
|
64
64
|
});
|
|
65
65
|
me.sessions = [];
|
|
66
|
-
|
|
67
|
-
var computer = me.networkGenerator.generateLocalComputer([user], 'test');
|
|
68
|
-
var location = computer.getHome(user);
|
|
69
|
-
me.localSession = new types_1.Session({
|
|
70
|
-
user: user,
|
|
71
|
-
computer: computer,
|
|
72
|
-
location: location
|
|
73
|
-
});
|
|
74
|
-
me.sessions.push(me.localSession);
|
|
66
|
+
me.setupLocalSession(localUser.username, localUser.password);
|
|
75
67
|
}
|
|
76
68
|
MockEnvironment.prototype.getComputerInLan = function (ipAddress, router) {
|
|
77
69
|
var me = this;
|
|
@@ -145,6 +137,27 @@ var MockEnvironment = /** @class */ (function () {
|
|
|
145
137
|
remote: true
|
|
146
138
|
});
|
|
147
139
|
};
|
|
140
|
+
MockEnvironment.prototype.setupLocalSession = function (username, password) {
|
|
141
|
+
var me = this;
|
|
142
|
+
var user = me.userGenerator.generate(username, password);
|
|
143
|
+
var computer = me.networkGenerator.generateLocalComputer([user], 'test');
|
|
144
|
+
var currentPath = computer.getHome(user);
|
|
145
|
+
var programPath = new types_1.File({
|
|
146
|
+
name: 'myprogramm',
|
|
147
|
+
permissions: '---------',
|
|
148
|
+
owner: 'root',
|
|
149
|
+
isProtected: true,
|
|
150
|
+
type: types_1.FileType.Bin
|
|
151
|
+
});
|
|
152
|
+
currentPath.putFile(programPath);
|
|
153
|
+
me.localSession = new types_1.Session({
|
|
154
|
+
user: user,
|
|
155
|
+
computer: computer,
|
|
156
|
+
currentPath: currentPath,
|
|
157
|
+
programPath: programPath
|
|
158
|
+
});
|
|
159
|
+
me.sessions.push(me.localSession);
|
|
160
|
+
};
|
|
148
161
|
MockEnvironment.prototype.getLatestSession = function () {
|
|
149
162
|
return this.sessions[this.sessions.length - 1];
|
|
150
163
|
};
|
|
@@ -204,15 +217,6 @@ var MockEnvironment = /** @class */ (function () {
|
|
|
204
217
|
}
|
|
205
218
|
return null;
|
|
206
219
|
};
|
|
207
|
-
MockEnvironment.prototype.getComputersOfRouterByIp = function (ipAddress) {
|
|
208
|
-
var me = this;
|
|
209
|
-
var router = me.getRouterByIp(ipAddress);
|
|
210
|
-
if (!router) {
|
|
211
|
-
return [];
|
|
212
|
-
}
|
|
213
|
-
var devices = Array.from(router.devices.values());
|
|
214
|
-
return devices.filter(function (d) { return d instanceof types_1.Computer; });
|
|
215
|
-
};
|
|
216
220
|
MockEnvironment.prototype.findRouterViaNS = function (name) {
|
|
217
221
|
var me = this;
|
|
218
222
|
var serverMap = me.networkGenerator.serverMap;
|
package/dist/fs.d.ts
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { Entity, Folder } from './types/file-system';
|
|
2
|
+
import { Port } from './types/port';
|
|
3
|
+
import { User } from './types/user';
|
|
4
|
+
export declare enum FSDeviceOwnerType {
|
|
5
|
+
Player = 0,
|
|
6
|
+
Npc = 1
|
|
7
|
+
}
|
|
8
|
+
export declare enum FSCreationVariation {
|
|
9
|
+
Easy = 0,
|
|
10
|
+
Medium = 1,
|
|
11
|
+
Hard = 2
|
|
12
|
+
}
|
|
13
|
+
export declare enum FSDeviceType {
|
|
14
|
+
Unknown = 0,
|
|
15
|
+
Computer = 1,
|
|
16
|
+
Router = 2,
|
|
17
|
+
Switch = 3
|
|
18
|
+
}
|
|
19
|
+
export interface FSOptions {
|
|
20
|
+
users: User[];
|
|
21
|
+
type: FSDeviceType;
|
|
22
|
+
ownerType: FSDeviceOwnerType;
|
|
23
|
+
difficulty?: FSCreationVariation;
|
|
24
|
+
parent?: Entity;
|
|
25
|
+
ports?: Map<number, Port>;
|
|
26
|
+
}
|
|
27
|
+
export declare function getUserFolder(options: FSOptions, user: string): Folder;
|
|
28
|
+
export declare function getDefaultFileSystem(options: FSOptions): Folder;
|