@liberstudio/cloudflare-list 2.2.0 → 2.2.1
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/README.md
CHANGED
|
@@ -35,6 +35,7 @@ import { CloudflareAttacksModule } from "@liberstudio/cloudflare-list";
|
|
|
35
35
|
apiToken: "<api_token>",
|
|
36
36
|
comment: "<comment>",
|
|
37
37
|
logPath: "<logPath>",
|
|
38
|
+
excludedPaths: "<excludedList>",
|
|
38
39
|
}),
|
|
39
40
|
],
|
|
40
41
|
})
|
|
@@ -52,12 +53,13 @@ import { CloudflareAttacksModule } from "@liberstudio/cloudflare-list";
|
|
|
52
53
|
imports: [ConfigModule],
|
|
53
54
|
inject: [ConfigService],
|
|
54
55
|
useFactory: (config: ConfigService) => ({
|
|
55
|
-
apiToken: config.getOrThrow<string>(
|
|
56
|
-
accountId: config.getOrThrow<string>(
|
|
57
|
-
listId: config.getOrThrow<string>(
|
|
58
|
-
comment: config.get<string>(
|
|
59
|
-
logPath: config.get<string>(
|
|
60
|
-
|
|
56
|
+
apiToken: config.getOrThrow<string>("CLOUDFLARE_API_TOKEN"),
|
|
57
|
+
accountId: config.getOrThrow<string>("CLOUDFLARE_ACCOUNT_ID"),
|
|
58
|
+
listId: config.getOrThrow<string>("CLOUDFLARE_LIST_ID"),
|
|
59
|
+
comment: config.get<string>("CLOUDFLARE_LIST_COMMENT") || "Blocked",
|
|
60
|
+
logPath: config.get<string>("CLOUDFLARE_LIST_LOG_PATH") || "/var/log/nestjs-attacks.log",
|
|
61
|
+
excludedPaths: ["/api/health", "/api/webhook", /^\/api\/public\/.*/],
|
|
62
|
+
}),
|
|
61
63
|
}),
|
|
62
64
|
],
|
|
63
65
|
})
|
|
@@ -65,4 +67,5 @@ export class AppModule {}
|
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
## License
|
|
70
|
+
|
|
68
71
|
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -42,7 +42,7 @@ let AttackLoggerMiddleware = AttackLoggerMiddleware_1 = class AttackLoggerMiddle
|
|
|
42
42
|
}
|
|
43
43
|
use(req, res, next) {
|
|
44
44
|
res.on("finish", () => {
|
|
45
|
-
if (res.statusCode === 404) {
|
|
45
|
+
if (res.statusCode === 404 && !this.isExcluded(req.url)) {
|
|
46
46
|
this.handleSuspicious(req);
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -94,6 +94,10 @@ let AttackLoggerMiddleware = AttackLoggerMiddleware_1 = class AttackLoggerMiddle
|
|
|
94
94
|
this.logger.log(`Cartella dei log creata: ${dir}`);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
isExcluded(url) {
|
|
98
|
+
const excluded = this.options.excludedPaths ?? [];
|
|
99
|
+
return excluded.some((p) => (p instanceof RegExp ? p.test(url) : url.startsWith(p)));
|
|
100
|
+
}
|
|
97
101
|
onModuleDestroy() {
|
|
98
102
|
this.stream.end();
|
|
99
103
|
for (const timeout of this.recentIps.values()) {
|