Skip to content

How to query types with a specific composite type in CodeQL Go? #9097

@cokeBeer

Description

@cokeBeer

I am working on defining a dataflow source for web framework Beego.
I tried this query on my project written in beego (https://github.com/cokeBeer/go-sec-code):

import go

from Type c
where  c.hasQualifiedName("go-sec-code/controllers", "CommandInjectVuln1Controller")
select c.getMethod("Get")

it turned out no results,but I do have a go-sec-code/controllers.CommandInjectVuln1Controller.Get Method
https://github.com/cokeBeer/go-sec-code/blob/main/controllers/commandInject.go#L23
image
I think the problem may come from that Beego.Controller is a composite type which looks like:

package controllers

import (
	"fmt"
	"go-sec-code/utils"
	"os/exec"

	beego "github.com/beego/beego/v2/server/web"
)

type CommandInjectVuln1Controller struct {
	beego.Controller
}

moreover, I've noted that there is a BeegoControllerSource in CodeQL Go standard library semmle.go.frameworks.Beego.qll.
image
I tried only query the souce node with vscode's help on the same project, but it turned out not found GetString() method called
image

How can I make a source defination that can find all Controllers that composite Beego.Controller?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions