-
Notifications
You must be signed in to change notification settings - Fork 103
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
add kolide_jwt parsing table #1440
Conversation
|
||
// attempt decode into the generic (default) MapClaims struct to ensure we capture | ||
// any claims data that might be useful | ||
token, _, err := new(jwt.Parser).ParseUnverified(string(tokenRaw), jwt.MapClaims{}) |
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.
What's the second return value?
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 parts = strings.Split(tokenString, ".")
- we are essentially just base64 decoding parts[1]
in the remaining bits
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.
Is there anything to extract from the other parts?
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.
we will get the header now too per the conversation below. I can include the raw signature as well if you think that would be helpful?
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 don't think we should return the raw signature. Or the contents of the file
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.
Doing it in pkg/dataflatten
is a little weird, but I think okay. Mostly, I think of things down in here as low level, and we can build atop them. And I'm not sure what's going to want to build on this. But 🤷 it's no different than plist. So it's probably fine?
OTOH, if we wanted to bring in validation, we'd need to refactor. OTOH, we could refactor if/when we care.
pkg/dataflatten/jwt.go
Outdated
for k, v := range claims { | ||
results[k] = v | ||
} |
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.
Do we need results
or can we pass claims
straight to Flatten?
And is there any more data we should pass back? Like, this is claims
, but is there more? I kinda want to return
struct {
Claims: map[string]any
}
Because then if we add validate, or file metadata, or ???, we won't need to change the structure.
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 can try that out! we could additionally include the header (likely containing the signing algo) but in general its just:
Header | Payload | Signature |
---|---|---|
algo | claims | signature |
type (=JWT) |
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.
Algo seems interesting. An issued timestamp if one exists...
And someday I think it would be super interesting to get a validation in, and that would give us a place to hang it. I guess we could preemptively add validated: false
or similar.
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.
we can't pass claims to flatten directly but that will work for the header and signature. the registered claim for timestamp will be at claims->iat
if included. and I will add a validated false
for clarity here, thank you!
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.
PR description is updated with the new format discussed here
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'm good with this as-is, but also like seph's suggestion https://github.com/kolide/launcher/pull/1440/files#r1383951951 -- happy to reapprove if you update
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.
Sweet!
As a side note, GitHub has special syntax for how to link PRs to Issues and have them mark them as closed and whatnot. https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
This adds a
kolide_jwt
table to parse claims from a JWT when queried against a file path containing one. The general functionality is similar to thekolide_json
table, requiring a valid path to an existing file, and parsing the contents where available:This closes #1327