Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features #135

Closed
wants to merge 9 commits into from
Closed

Features #135

wants to merge 9 commits into from

Conversation

croessner
Copy link
Owner

No description provided.

Christian Roessner added 9 commits October 15, 2024 14:40
Implemented a ConnectionManager to track and manage network connections. Added Lua bindings for registering and querying connection targets, as well as Prometheus metric for active connections. Updated project dependencies to support this feature.

Signed-off-by: Christian Roessner <[email protected]>
Implemented a ConnectionManager to track and manage network connections. Added Lua bindings for registering and querying connection targets, as well as Prometheus metric for active connections. Updated project dependencies to support this feature.

Signed-off-by: Christian Roessner <[email protected]>
# Conflicts:
#	server/lualib/connmgr/netstats.go
Introduced the `GenericConnections` metric to track active connections with labels for description, target, and direction. Added support for registering connection targets with descriptions and provided a new function to update the connection metrics dynamically.

Signed-off-by: Christian Roessner <[email protected]>
Implement `validateDNSResolver` to ensure DNS resolver entries are in valid host:port format in the Server configuration. Adjust `NewDNSResolver` to use the provided resolver setting directly, aligning with the new validation checks.

Signed-off-by: Christian Roessner <[email protected]>
Integrated nauthilus_psnet module across haveibeenpwnd, blocklist, backend, and geoip Lua plugins. This inclusion enables registering remote connection targets for enhanced network communication handling.

Signed-off-by: Christian Roessner <[email protected]>
Update the connection target to include the port 443 for secure communication. This change ensures that the HTTP request to the pwnedpasswords API is correctly routed and handled.

Signed-off-by: Christian Roessner <[email protected]>
Centralize HTTP client initialization with consistent settings across various packages by introducing InitHTTPClient method. The global httpClient variable is now pre-configured once at startup, eliminating redundant client creation and closure, resulting in cleaner and more maintainable code.

Signed-off-by: Christian Roessner <[email protected]>
Introduced a ticker-based IP monitoring system to the ConnectionManager to check for IP updates at regular intervals. This includes adding `StartMonitoring` and auxiliary functions such as `equalIPs`, and `checkForIPUpdates`, as well as integrating the new monitoring process into the server's lifecycle.

Signed-off-by: Christian Roessner <[email protected]>

for _, ip := range m.ipTargets[target] {
if ip == "0.0.0.0" || ip == "::" || ip == addr.IP {
if addr.Port == uint32(port) {

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of an integer with architecture-dependent bit size from
strconv.Atoi
to a lower bit size type uint32 without an upper bound check.

Copilot Autofix AI 4 months ago

To fix the problem, we need to ensure that the integer value parsed from the string is within the valid range for uint32 before performing the cast. This can be achieved by using strconv.ParseUint with a specified bit size of 32, which will directly return a uint64 value. We can then safely cast this value to uint32 after ensuring it is within the valid range.

  • Replace the use of strconv.Atoi with strconv.ParseUint specifying a bit size of 32.
  • Ensure the parsed value is within the valid range for uint32 before casting.
Suggested changeset 1
server/lualib/connmgr/netstats.go

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/server/lualib/connmgr/netstats.go b/server/lualib/connmgr/netstats.go
--- a/server/lualib/connmgr/netstats.go
+++ b/server/lualib/connmgr/netstats.go
@@ -246,3 +246,3 @@
 
-		port, err := strconv.Atoi(portStr)
+		port64, err := strconv.ParseUint(portStr, 10, 32)
 		if err != nil {
@@ -252,2 +252,3 @@
 		}
+		port := uint32(port64)
 
@@ -265,3 +266,3 @@
 				if ip == "0.0.0.0" || ip == "::" || ip == addr.IP {
-					if addr.Port == uint32(port) {
+					if addr.Port == port {
 						count++
EOF
@@ -246,3 +246,3 @@

port, err := strconv.Atoi(portStr)
port64, err := strconv.ParseUint(portStr, 10, 32)
if err != nil {
@@ -252,2 +252,3 @@
}
port := uint32(port64)

@@ -265,3 +266,3 @@
if ip == "0.0.0.0" || ip == "::" || ip == addr.IP {
if addr.Port == uint32(port) {
if addr.Port == port {
count++
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@croessner croessner closed this Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant