Remove vendored path prefix of vendored packages

This commit is contained in:
Sauyon Lee
2020-02-03 14:58:23 -08:00
parent c94f5dafb3
commit 9a9561bb12
8 changed files with 65 additions and 1 deletions

View File

@@ -12,7 +12,11 @@ class Package extends @package {
string getName() { packages(this, result, _, _) }
/** Gets the path of this package. */
string getPath() { packages(this, _, result, _) }
string getPath() {
exists(string fullPath | packages(this, _, fullPath, _) |
result = fullPath.regexpReplaceAll("^.*/vendor/", "")
)
}
/** Gets the scope of this package. */
PackageScope getScope() { packages(this, _, _, result) }

View File

@@ -0,0 +1,31 @@
| package errors | errors |
| package fmt | fmt |
| package github.com/github/codeql-go/ql/test/library-tests/semmle/go/main | github.com/github/codeql-go/ql/test/library-tests/semmle/go/main |
| package github.com/nonexistent-test-pkg | github.com/nonexistent-test-pkg |
| package internal/bytealg | internal/bytealg |
| package internal/cpu | internal/cpu |
| package internal/fmtsort | internal/fmtsort |
| package internal/oserror | internal/oserror |
| package internal/poll | internal/poll |
| package internal/race | internal/race |
| package internal/reflectlite | internal/reflectlite |
| package internal/syscall/unix | internal/syscall/unix |
| package internal/testlog | internal/testlog |
| package io | io |
| package math | math |
| package math/bits | math/bits |
| package os | os |
| package reflect | reflect |
| package runtime | runtime |
| package runtime/internal/atomic | runtime/internal/atomic |
| package runtime/internal/math | runtime/internal/math |
| package runtime/internal/sys | runtime/internal/sys |
| package sort | sort |
| package strconv | strconv |
| package sync | sync |
| package sync/atomic | sync/atomic |
| package syscall | syscall |
| package time | time |
| package unicode | unicode |
| package unicode/utf8 | unicode/utf8 |
| package unsafe | unsafe |

View File

@@ -0,0 +1,4 @@
import go
from Package pkg
select pkg, pkg.getPath()

View File

@@ -0,0 +1,5 @@
module github.com/github/codeql-go/ql/test/library-tests/semmle/go/main
go 1.13
require github.com/nonexistent-test-pkg v0.0.0-20200203000000-0000000000000

View File

@@ -0,0 +1,12 @@
package main
import (
"fmt"
"github.com/nonexistent-test-pkg"
)
func main() {
pkg.Foo()
fmt.Println("")
}

View File

@@ -0,0 +1 @@
This is a simple stub package, strictly for use in query testing.

View File

@@ -0,0 +1,5 @@
package pkg
func Foo() string {
return "foo"
}

View File

@@ -0,0 +1,2 @@
# github.com/nonexistent-test-pkg v0.0.0-20200203000000-0000000000000
github.com/nonexistent-test-package