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

interp: fix type assertion issues #1524

Merged
merged 2 commits into from
Mar 14, 2023
Merged

interp: fix type assertion issues #1524

merged 2 commits into from
Mar 14, 2023

Conversation

ssbeatty
Copy link
Contributor

@ssbeatty ssbeatty commented Mar 14, 2023

closes #1514

hi!
I had the same problem as #1514 and I wanted to fix it, I found
When asserting *crypto/rsa.PublicKey, using the typ attribute of node to get an nil rtype, resulting in the assertion result being nok

This code contains the same problem

package main

import (
	"log"
	"crypto/rsa"
)

func main() {

    var pKey interface{} = &rsa.PublicKey{}

    if _, ok := pKey.(*rsa.PublicKey); ok {
        log.Println("ok")
    } else {
        log.Println("nok")
    }
}

So I submitted this Pull Request, hope it will be merged

@CLAassistant
Copy link

CLAassistant commented Mar 14, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@mvertes mvertes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thank you for this excellent first submission.

Can you also add your test sample as _test/assert3.go so we have a good non regression test for this ?

I changed it to avoid using log.Println which displays a different date at each run, not suitable for reproduction and added expected output comment so it can be checked by the test suite.

Thanks again

package main

import "crypto/rsa"

func main() {
    var pKey interface{} = &rsa.PublicKey{}

    if _, ok := pKey.(*rsa.PublicKey); ok {
        println("ok")
    } else {
        println("nok")
    }
}

// Output:
// ok

@mvertes mvertes added bug Something isn't working area/core labels Mar 14, 2023
@mvertes mvertes added this to the v0.15.x milestone Mar 14, 2023
@ssbeatty
Copy link
Contributor Author

Thank you very much for your reply, I added new test file for this use case

@traefiker traefiker merged commit 9d65860 into traefik:master Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected behavior checking Public PEM key with github.com/golang-jwt/jwt package
4 participants