-
Notifications
You must be signed in to change notification settings - Fork 23
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
🐛 fix github discovery for v9 #1655
Conversation
393c670
to
018fc64
Compare
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.
Thanks for fixing this @vjeffrey
I gave it a try:
To me, it looks like the discovery of the repos is working. But then some data is missing to actually create the repo resource. |
018fc64
to
17c7b32
Compare
if i try to run the command you tried in v8, i also error --- i think it needs to be:
|
17c7b32
to
06cf4ca
Compare
I did a bit more testing. My first command was wrong, but what I tried to achieve, works in v8 in case you use the correct parameters:
In my first try, I used the wrong discovery option: But using the correct discovery in v9, does not show the same result as in v8. |
Also the error message in my first try was misleading. I opened a PR to fix this: #1657 |
06cf4ca
to
2714913
Compare
alright, this is fixed up now, |
hmm, actually i have the platform ids, they look a little off |
The discovery options are different for v8:
v9:
And as already mentioned the platformIDs: "Mondoo Inc" vs. "mondoohq" |
7b18f8f
to
bc61623
Compare
}) | ||
} | ||
} | ||
if stringx.Contains(targets, connection.DiscoveryUsers) { |
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.
Nice! That's actually a new feature. We don't have this in v8.
// TODO: figure out if the client has the permission to fetch the protection rules | ||
return nil, 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.
@vjeffrey I'd like your opinion on this one.
When I keep it as is, this panics:
cnquery run github repo czunker/go-vex -c "github.repository{ name branches[0]{*} commits[0]{*} }"
! using builtin provider for github
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
! using builtin provider for github
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1180360]
goroutine 14 [running]:
go.mondoo.com/cnquery/providers/github/resources.(*mqlGithubBranchprotection).MqlID(0x2f0000c000cd04ea?)
/home/christian/workspace/mondoo/github.com/cnquery/providers/github/resources/github.lr.go:3937
go.mondoo.com/cnquery/llx.resource2result({0x22861a0, 0x0}, {0xc000fea348, 0x18})
/home/christian/workspace/mondoo/github.com/cnquery/llx/data_conversions.go:313 +0x52
When I only create a resource with an ID, it prevents the panic, but I get "cannot convert" error.
In v8, this simply displayed as "null":
cnquery run github repo czunker/go-vex -c "github.repository{ name branches[0]{ name protectionRules {*} } commits[0]{ sha commit {*}} }"
...
github.repository: {
...
name: "go-vex"
branches[0]: {
protectionRules: null
name: "christian/extend_csaf_advisories"
}
}
This change works, but is quite different from v8. Also, this might apply to other resources.
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'll check that out, i think i ran into that before on aws
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 looks like it's an issue not limited to this resource -- returning nil in these types of situations isn't behaving the way we expect it to - so we can probably move this pr forward and fix that in a followup
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 rebased this on main, as #1726 was merged.
I changed the field accordingly, and now it looks good:
nquery run github repo czunker/go-vex -c "github.repository{ name branches[0]{ name protectionRules {*} }}" --verbose
DBG using provider github with connector github
DBG no need to update provider last-refresh=29.146104804s provider=github
DBG running provider plugin path=/home/christian/.config/mondoo/providers/github/github
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source default
DBG resolved 1 assets
...
github.repository: {
name: "go-vex"
branches[0]: {
protectionRules: null
name: "christian/extend_csaf_advisories"
}
}
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.
awesome! thank you @arlimus for that fix!
Signed-off-by: Christian Zunker <[email protected]>
Signed-off-by: Christian Zunker <[email protected]>
517017a
to
0d12aa8
Compare
I gave some other fields a try where we also return
@vjeffrey I think this PR is done for now, or do you see any open topics? |
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.
LGTM. @vjeffrey should have another look as I also did part of the commits.
just tested again, this is working great, lets get it in! |
fixes #1644