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

Rafal/ai video remoteaiworker pr rebase fixed tests #3198

Draft
wants to merge 73 commits into
base: ai-video
Choose a base branch
from

Conversation

leszko
Copy link
Contributor

@leszko leszko commented Oct 3, 2024

No description provided.

ad-astra-video and others added 30 commits September 5, 2024 08:50
…through. small update to aiResults endpoint and related test update
@leszko leszko changed the base branch from master to ai-video October 3, 2024 12:15

authType := r.Header.Get("Authorization")
if protoVerAIWorker != authType {
glog.Error("Invalid auth type ", authType)

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

Sensitive data returned by HTTP request headers
flows to a logging call.

Copilot Autofix AI 21 days ago

To fix the problem, we should avoid logging the sensitive authType value directly. Instead, we can log a generic message indicating an invalid authorization type without including the actual value. This approach maintains the functionality of logging errors while protecting sensitive information.

  • Modify the logging statement on line 533 to remove the authType value.
  • Ensure that the log message still provides useful information for debugging without exposing sensitive data.
Suggested changeset 1
server/ai_http.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/ai_http.go b/server/ai_http.go
--- a/server/ai_http.go
+++ b/server/ai_http.go
@@ -532,3 +532,3 @@
 		if protoVerAIWorker != authType {
-			glog.Error("Invalid auth type ", authType)
+			glog.Error("Invalid auth type")
 			http.Error(w, "Unauthorized", http.StatusUnauthorized)
EOF
@@ -532,3 +532,3 @@
if protoVerAIWorker != authType {
glog.Error("Invalid auth type ", authType)
glog.Error("Invalid auth type")
http.Error(w, "Unauthorized", http.StatusUnauthorized)
Copilot is powered by AI and may make mistakes. Always verify output.
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
}

func runAIWorker(n *core.LivepeerNode, orchAddr string, capacity int, caps *net.Capabilities) error {
tlsConfig := &tls.Config{InsecureSkipVerify: true}

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.

Copilot Autofix AI 21 days ago

To fix the problem, we need to ensure that TLS certificate verification is enabled. This involves removing the InsecureSkipVerify: true setting and properly configuring the TLS settings to use valid certificates.

  1. Remove InsecureSkipVerify: true: This setting should be removed from the tls.Config initialization.
  2. Load system CA certificates: Use the system's CA certificates to verify the server's certificate.
  3. Handle errors appropriately: Ensure that any errors related to TLS configuration are properly handled.
Suggested changeset 1
server/ai_worker.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/ai_worker.go b/server/ai_worker.go
--- a/server/ai_worker.go
+++ b/server/ai_worker.go
@@ -96,7 +96,12 @@
 func runAIWorker(n *core.LivepeerNode, orchAddr string, capacity int, caps *net.Capabilities) error {
-	tlsConfig := &tls.Config{InsecureSkipVerify: true}
+	tlsConfig := &tls.Config{}
+	creds, err := credentials.NewClientTLSFromFile("/path/to/ca-certificates.crt", "")
+	if err != nil {
+		glog.Error("Failed to load CA certificates: ", err)
+		return err
+	}
 	conn, err := grpc.Dial(orchAddr,
-		grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
+		grpc.WithTransportCredentials(creds))
 	if err != nil {
-		glog.Error("Did not connect AI worker to orchesrator: ", err)
+		glog.Error("Did not connect AI worker to orchestrator: ", err)
 		return err
@@ -130,3 +135,3 @@
 
-	httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
+	httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{}}}
 	var wg sync.WaitGroup
EOF
@@ -96,7 +96,12 @@
func runAIWorker(n *core.LivepeerNode, orchAddr string, capacity int, caps *net.Capabilities) error {
tlsConfig := &tls.Config{InsecureSkipVerify: true}
tlsConfig := &tls.Config{}
creds, err := credentials.NewClientTLSFromFile("/path/to/ca-certificates.crt", "")
if err != nil {
glog.Error("Failed to load CA certificates: ", err)
return err
}
conn, err := grpc.Dial(orchAddr,
grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
grpc.WithTransportCredentials(creds))
if err != nil {
glog.Error("Did not connect AI worker to orchesrator: ", err)
glog.Error("Did not connect AI worker to orchestrator: ", err)
return err
@@ -130,3 +135,3 @@

httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{}}}
var wg sync.WaitGroup
Copilot is powered by AI and may make mistakes. Always verify output.
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
}
}()

httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.

Copilot Autofix AI 21 days ago

To fix the problem, we need to ensure that TLS certificate verification is enabled. This involves setting up proper TLS configuration with valid certificates. The best way to fix this without changing existing functionality is to remove the InsecureSkipVerify: true setting and ensure that the application uses valid certificates for TLS communication.

  1. Remove the InsecureSkipVerify: true setting: This will enforce the default behavior of verifying the server's certificate chain and host name.
  2. Ensure valid certificates are used: This might involve configuring the application to use a certificate authority (CA) or providing the necessary certificates.
Suggested changeset 1
server/ai_worker.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/ai_worker.go b/server/ai_worker.go
--- a/server/ai_worker.go
+++ b/server/ai_worker.go
@@ -130,3 +130,3 @@
 
-	httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
+	httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{}}}
 	var wg sync.WaitGroup
EOF
@@ -130,3 +130,3 @@

httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
httpc := &http.Client{Transport: &http2.Transport{TLSClientConfig: &tls.Config{}}}
var wg sync.WaitGroup
Copilot is powered by AI and may make mistakes. Always verify output.
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
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.

2 participants