generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from NethServer/unbanTable
Crowdsec add an Unban Page
- Loading branch information
Showing
12 changed files
with
1,882 additions
and
1,253 deletions.
There are no files selected for viewing
This file contains 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,14 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# list the current banned IP | ||
|
||
list=$(podman exec $MODULE_ID cscli decisions list --output json) | ||
|
||
if [[ $list == 'null' ]];then | ||
echo '[]' | ||
else | ||
echo $list | ||
fi |
This file contains 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,24 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
import json | ||
import sys | ||
import agent | ||
import os | ||
|
||
|
||
request = json.load(sys.stdin) | ||
ip = request['ip'] | ||
action = request['action'] | ||
module_id = os.environ["MODULE_ID"] | ||
|
||
if action == 'unban': | ||
agent.run_helper("podman", "exec", module_id, "cscli", "decision", "delete", "-i", ip).check_returncode() | ||
elif action == 'unban_all': | ||
agent.run_helper("podman", "exec", module_id, "cscli", "decision", "delete", "--all").check_returncode() | ||
else: | ||
sys.exit(2) |
This file contains 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,33 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "unban-ip input", | ||
"$id": "http://schema.nethserver.org/mail/unban-ip.json", | ||
"description": "flush the postfix queue email", | ||
"examples": [ | ||
{ | ||
"queue": "1.2.3.4", | ||
"action": "unban" | ||
} | ||
], | ||
"type": "object", | ||
"required": [ | ||
"ip", | ||
"action" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"ip": { | ||
"type": "string", | ||
"title": "IP", | ||
"description": "IP to unban", | ||
"minLength": 1 | ||
}, | ||
"action": { | ||
"type": "string", | ||
"format": "regex", | ||
"pattern": "^(unban|unban_all)$", | ||
"title": "Unban action", | ||
"description": "Manage to unban IP" | ||
} | ||
} | ||
} |
This file contains 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 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 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 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,38 @@ | ||
<!-- | ||
Copyright (C) 2023 Nethesis S.r.l. | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
--> | ||
<template> | ||
<NsModal | ||
size="default" | ||
:visible="isShown" | ||
@modal-hidden="$emit('hide')" | ||
@primary-click="$emit('confirm')" | ||
> | ||
<template slot="title" | ||
>{{ $t("unban.unban_ip") }}: {{ ban.value }}</template | ||
> | ||
<template slot="content"> | ||
<div>{{ $t("unban.confirm_unban_ip_message") }}</div> | ||
</template> | ||
<template slot="secondary-button">{{ core.$t("common.cancel") }}</template> | ||
<template slot="primary-button">{{ $t('unban.delete') }}</template> | ||
</NsModal> | ||
</template> | ||
|
||
<script> | ||
import { UtilService, IconService } from "@nethserver/ns8-ui-lib"; | ||
export default { | ||
name: "ConfirmRelaseIP", | ||
mixins: [UtilService, IconService], | ||
props: { | ||
isShown: Boolean, | ||
ban: { type: [Object, null] }, | ||
core: { type: Object }, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import "../styles/carbon-utils"; | ||
</style> |
This file contains 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,35 @@ | ||
<!-- | ||
Copyright (C) 2023 Nethesis S.r.l. | ||
SPDX-License-Identifier: GPL-3.0-or-later | ||
--> | ||
<template> | ||
<NsModal | ||
size="default" | ||
:visible="isShown" | ||
@modal-hidden="$emit('hide')" | ||
@primary-click="$emit('confirm')" | ||
> | ||
<template slot="title">{{ $t("unban.release_all_ip") }}</template> | ||
<template slot="content"> | ||
<div>{{ $t("unban.confirm_delete_all_bans_message") }}</div> | ||
</template> | ||
<template slot="secondary-button">{{ core.$t("common.cancel") }}</template> | ||
<template slot="primary-button">{{ $t('unban.delete') }}</template> | ||
</NsModal> | ||
</template> | ||
|
||
<script> | ||
import { UtilService, IconService } from "@nethserver/ns8-ui-lib"; | ||
export default { | ||
name: "UnbanIPAll", | ||
mixins: [UtilService, IconService], | ||
props: { | ||
isShown: Boolean, | ||
core: { type: Object }, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import "../styles/carbon-utils"; | ||
</style> |
This file contains 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 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.