-
Notifications
You must be signed in to change notification settings - Fork 600
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
RequestReply: Add CESQL function #8360
base: main
Are you sure you want to change the base?
Conversation
The committers listed above are authorized under a signed CLA. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: d3akhtar The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @d3akhtar! It looks like this is your first PR to knative/eventing 🎉 |
Hi @d3akhtar. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return false, errors.New("correlationId Format: <original id>:<base64/hex encoded encrypted id>") | ||
} | ||
|
||
slice := strings.Split(correlationId, ":") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
key, keyFieldExists := secret.Data["key"] | ||
algorithm, algorithmFieldExists := secret.Data["algorithm"] | ||
|
||
if keyFieldExists && algorithmFieldExists && secretNamesToTry[secret.Name] { | ||
var decryptionFunc func(originalId string, encryptedIdBytes []byte, key []byte) (bool, error) | ||
switch strings.ToUpper(string(algorithm)) { | ||
case "AES", "AES-ECB": | ||
decryptionFunc = compareWithAES | ||
case "DES": | ||
decryptionFunc = compareWithDES | ||
case "3DES", "TRIPLEDES": | ||
decryptionFunc = compareWithTripleDES | ||
case "RC4": | ||
decryptionFunc = compareWithRC4 | ||
default: | ||
return false, errors.New("cipher algorithm not supported") | ||
} | ||
|
||
res, err := decryptionFunc(originalId, encryptedIdBytes, key) | ||
if err != nil { | ||
return false, err | ||
} | ||
if res { | ||
return true, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might split this out into its own function
}, | ||
) | ||
|
||
ceruntime.AddFunction(correlationIdFilterFunction) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might add this to the runtime somewhere else, since this will be called to make a new CESQL expression as well. The function is doing a bit too much. There should be 2 functions:
- Make and add the CESQL function
- Parse the CESQL expression into a filter
// Assuming .kube/config is in the home directory | ||
basePath, _ := os.UserHomeDir() | ||
defaultKubeConfigPath := path.Join(basePath, ".kube", "config") | ||
|
||
// Set up k8s client to get secrets | ||
config, err := clientcmd.BuildConfigFromFlags("", defaultKubeConfigPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
clientset, err := kubernetes.NewForConfig(config) | ||
if err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done for you, you can import
kubeclient "knative.dev/pkg/client/injection/kube/client" |
if err != nil { | ||
return nil, err | ||
} | ||
secrets, err := clientset.CoreV1().Secrets("default").List(context.Background(), metav1.ListOptions{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably need to configure:
- which namespace to look up secrets in
- which secret names to get
@d3akhtar: The following tests failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Fixes #8318
Proposed Changes
Pre-review Checklist
Release Note
Docs