Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5e2b93

Browse files
committed
Ruby: add API graph label for content
1 parent e104b65 commit d5e2b93

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

ruby/ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,8 @@ module API {
754754
any(DataFlowDispatch::ParameterPosition c).isPositional(n)
755755
} or
756756
MkLabelBlockParameter() or
757-
MkLabelEntryPoint(EntryPoint name)
757+
MkLabelEntryPoint(EntryPoint name) or
758+
MkLabelContent(DataFlow::Content content)
758759
}
759760

760761
/** Provides classes modeling the various edges (labels) in the API graph. */
@@ -844,6 +845,20 @@ module API {
844845
/** Gets the name of the entry point. */
845846
API::EntryPoint getName() { result = name }
846847
}
848+
849+
/** A label representing contents of an object. */
850+
class LabelContent extends ApiLabel, MkLabelContent {
851+
private DataFlow::Content content;
852+
853+
LabelContent() { this = MkLabelContent(content) }
854+
855+
override string toString() {
856+
result = "getContent(" + content.toString().replaceAll(" ", "_") + ")"
857+
}
858+
859+
/** Gets the content represented by this label. */
860+
DataFlow::Content getContent() { result = content }
861+
}
847862
}
848863

849864
/** Gets the `member` edge label for member `m`. */
@@ -870,6 +885,9 @@ module API {
870885
/** Gets the label for the edge from the root node to a custom entry point of the given name. */
871886
LabelEntryPoint entryPoint(API::EntryPoint name) { result.getName() = name }
872887

888+
/** Gets a label representing the given content. */
889+
LabelContent content(DataFlow::Content content) { result.getContent() = content }
890+
873891
/** Gets the API graph label corresponding to the given argument position. */
874892
Label::ApiLabel getLabelFromArgumentPosition(DataFlowDispatch::ArgumentPosition pos) {
875893
exists(int n |

0 commit comments

Comments
 (0)