Use shorter naming scheme for types

This commit is contained in:
Owen Mansel-Chan 2024-09-24 07:24:48 +01:00
Родитель 6a67bd52a9
Коммит 279800ea62
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 67E427E02E6DA1B8
28 изменённых файлов: 338 добавлений и 68 удалений

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SEmbedI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SEmbedI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SEmbedI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,22 @@
invalidModelRow
paths
| test.go:14:7:14:16 | call to Source | test.go:16:9:16:9 | y |
| test.go:26:7:26:16 | call to Source | test.go:28:9:28:9 | y |
| test.go:38:7:38:16 | call to Source | test.go:40:9:40:9 | y |
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
sources
| test.go:14:7:14:16 | call to Source |
| test.go:26:7:26:16 | call to Source |
| test.go:38:7:38:16 | call to Source |
| test.go:50:7:50:16 | call to Source |
| test.go:62:7:62:16 | call to Source |
| test.go:74:7:74:16 | call to Source |
sinks
| test.go:16:9:16:9 | y |
| test.go:28:9:28:9 | y |
| test.go:40:9:40:9 | y |
| test.go:52:9:52:9 | y |
| test.go:64:9:64:9 | y |
| test.go:76:9:76:9 | y |

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SEmbedI2", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SEmbedI2", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SEmbedI2", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -16,5 +16,3 @@ query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(s
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
// predicate foo() {
// }

Просмотреть файл

@ -0,0 +1,4 @@
invalidModelRow
paths
sources
sinks

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SEmbedS1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SEmbedS1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SEmbedS1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -0,0 +1,4 @@
invalidModelRow
paths
sources
sinks

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SEmbedS2", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SEmbedS2", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SEmbedS2", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -0,0 +1,22 @@
invalidModelRow
paths
| test.go:14:7:14:16 | call to Source | test.go:16:9:16:9 | y |
| test.go:26:7:26:16 | call to Source | test.go:28:9:28:9 | y |
| test.go:38:7:38:16 | call to Source | test.go:40:9:40:9 | y |
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
sources
| test.go:14:7:14:16 | call to Source |
| test.go:26:7:26:16 | call to Source |
| test.go:38:7:38:16 | call to Source |
| test.go:50:7:50:16 | call to Source |
| test.go:62:7:62:16 | call to Source |
| test.go:74:7:74:16 | call to Source |
sinks
| test.go:16:9:16:9 | y |
| test.go:28:9:28:9 | y |
| test.go:40:9:40:9 | y |
| test.go:52:9:52:9 | y |
| test.go:64:9:64:9 | y |
| test.go:76:9:76:9 | y |

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI2", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI2", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SImplEmbedI2", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -0,0 +1,7 @@
invalidModelRow
paths
| test.go:68:7:68:16 | call to Source | test.go:70:9:70:9 | y |
sources
| test.go:68:7:68:16 | call to Source |
sinks
| test.go:70:9:70:9 | y |

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -0,0 +1,7 @@
invalidModelRow
paths
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
sources
| test.go:74:7:74:16 | call to Source |
sinks
| test.go:76:9:76:9 | y |

Просмотреть файл

@ -0,0 +1,16 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS2", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS2", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "SImplEmbedS2", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -0,0 +1,18 @@
import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { sources(source) }
predicate isSink(DataFlow::Node sink) { sinks(sink) }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

Просмотреть файл

@ -1,16 +0,0 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingAndOverridingI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingAndOverridingI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingAndOverridingI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -1,16 +0,0 @@
extensions:
- addsTo:
pack: codeql/go-all
extensible: sourceModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
- addsTo:
pack: codeql/go-all
extensible: summaryModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
- addsTo:
pack: codeql/go-all
extensible: sinkModel
data:
- ["github.com/nonexistent/test", "StructEmbeddingI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]

Просмотреть файл

@ -28,49 +28,49 @@ func TestS2(t test.S2) {
t.Sink(y)
}
func TestStructEmbeddingI1(t test.StructEmbeddingI1) {
func TestSEmbedI1(t test.SEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingI2(t test.StructEmbeddingI2) {
func TestSEmbedI2(t test.SEmbedI2) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingAndOverridingI1(t test.StructEmbeddingAndOverridingI1) {
func TestSImplEmbedI1(t test.SImplEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingAndOverridingI2(t test.StructEmbeddingAndOverridingI2) {
func TestSImplEmbedI2(t test.SImplEmbedI2) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingS1(t test.StructEmbeddingS1) {
func TestSEmbedS1(t test.SEmbedS1) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingS2(t test.StructEmbeddingS2) {
func TestSEmbedS2(t test.SEmbedS2) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingAndOverridingS1(t test.StructEmbeddingAndOverridingS1) {
func TestSImplEmbedS1(t test.SImplEmbedS1) {
x := t.Source()
y := t.Step(x)
t.Sink(y)
}
func TestStructEmbeddingAndOverridingS2(t test.StructEmbeddingAndOverridingS2) {
func TestSImplEmbedS2(t test.SImplEmbedS2) {
x := t.Source()
y := t.Step(x)
t.Sink(y)

Просмотреть файл

@ -12,7 +12,7 @@ type I2 interface {
Source() interface{}
Step(interface{}) interface{}
Sink(interface{})
ExtraMethod()
ExtraMethodI2()
}
// A struct type implementing I1
@ -41,72 +41,74 @@ func (t *S2) Step(val interface{}) interface{} {
return val
}
func (t *S2) ExtraMethod() {}
func (t *S2) ExtraMethodI2() {}
// A struct type embedding I1
type StructEmbeddingI1 struct{ I1 }
type SEmbedI1 struct{ I1 }
// A struct type embedding I2
type StructEmbeddingI2 struct{ I2 }
type SEmbedI2 struct{ I2 }
// A struct type embedding I1 and "overriding" its methods
type StructEmbeddingAndOverridingI1 struct{ I1 }
// A struct type embedding I1 and separately implementing its methods, so the
// methods of the embedded field are not promoted.
type SImplEmbedI1 struct{ I1 }
func (t *StructEmbeddingAndOverridingI1) Source() interface{} {
func (t *SImplEmbedI1) Source() interface{} {
return nil
}
func (t *StructEmbeddingAndOverridingI1) Sink(interface{}) {}
func (t *SImplEmbedI1) Sink(interface{}) {}
func (t *StructEmbeddingAndOverridingI1) Step(val interface{}) interface{} {
func (t *SImplEmbedI1) Step(val interface{}) interface{} {
return val
}
// A struct type embedding I2 and "overriding" its methods
type StructEmbeddingAndOverridingI2 struct{ I2 }
// A struct type embedding I2 and separately implementing its methods, so the
// methods of the embedded field are not promoted.
type SImplEmbedI2 struct{ I2 }
func (t *StructEmbeddingAndOverridingI2) Source() interface{} {
func (t *SImplEmbedI2) Source() interface{} {
return nil
}
func (t *StructEmbeddingAndOverridingI2) Sink(interface{}) {}
func (t *SImplEmbedI2) Sink(interface{}) {}
func (t *StructEmbeddingAndOverridingI2) Step(val interface{}) interface{} {
func (t *SImplEmbedI2) Step(val interface{}) interface{} {
return val
}
func (t *StructEmbeddingAndOverridingI2) ExtraMethod() {}
func (t *SImplEmbedI2) ExtraMethodI2() {}
// A struct type embedding S1
type StructEmbeddingS1 struct{ S1 }
type SEmbedS1 struct{ S1 }
// A struct type embedding S2
type StructEmbeddingS2 struct{ S2 }
type SEmbedS2 struct{ S2 }
// A struct type embedding S1 and "overriding" its methods
type StructEmbeddingAndOverridingS1 struct{ S1 }
type SImplEmbedS1 struct{ S1 }
func (t *StructEmbeddingAndOverridingS1) Source() interface{} {
func (t *SImplEmbedS1) Source() interface{} {
return nil
}
func (t *StructEmbeddingAndOverridingS1) Sink(interface{}) {}
func (t *SImplEmbedS1) Sink(interface{}) {}
func (t *StructEmbeddingAndOverridingS1) Step(val interface{}) interface{} {
func (t *SImplEmbedS1) Step(val interface{}) interface{} {
return val
}
// A struct type embedding S2 and "overriding" its methods
type StructEmbeddingAndOverridingS2 struct{ S2 }
type SImplEmbedS2 struct{ S2 }
func (t *StructEmbeddingAndOverridingS2) Source() interface{} {
func (t *SImplEmbedS2) Source() interface{} {
return nil
}
func (t *StructEmbeddingAndOverridingS2) Sink(interface{}) {}
func (t *SImplEmbedS2) Sink(interface{}) {}
func (t *StructEmbeddingAndOverridingS2) Step(val interface{}) interface{} {
func (t *SImplEmbedS2) Step(val interface{}) interface{} {
return val
}
func (t *StructEmbeddingAndOverridingS2) ExtraMethod() {}
func (t *SImplEmbedS2) ExtraMethodI2() {}