зеркало из https://github.com/github/codeql.git
Python docs: Replace remaining references to old 'Object' API are replaced by new 'Value' API.
(cherry picked from commit 6edf9efe1b
)
This commit is contained in:
Родитель
1bd0c69f0e
Коммит
ff64aedc0a
|
@ -297,28 +297,28 @@ The ``SsaVariable`` class represents `static single assignment form <http://en.w
|
|||
Type-inference classes
|
||||
----------------------
|
||||
|
||||
The QL library for Python also supplies some classes for accessing the inferred types of values. The classes ``Object`` and ``ClassObject`` allow you to query the possible classes that an expression may have at runtime. For example, which ``ClassObjects`` are iterable can be determined using the query:
|
||||
The QL library for Python also supplies some classes for accessing the inferred types of values. The classes ``Value`` and ``ClassValue`` allow you to query the possible classes that an expression may have at runtime. For example, which ``ClassValue``\ s are iterable can be determined using the query:
|
||||
|
||||
**Find iterable ``ClassObjects``**
|
||||
**Find iterable ``ClassValue``\ s**
|
||||
|
||||
.. code-block:: ql
|
||||
|
||||
import python
|
||||
|
||||
from ClassObject cls
|
||||
from ClassValue cls
|
||||
where cls.hasAttribute("__iter__")
|
||||
select cls
|
||||
|
||||
➤ `See this in the query console <https://lgtm.com/query/688180005/>`__ This query returns a list of classes for the projects analyzed. If you want to include the results for `builtin classes <http://docs.python.org/library/stdtypes.html>`__, which do not have any Python source code, show the non-source results.
|
||||
➤ `See this in the query console <https://lgtm.com/query/5151030165280978402/>`__ This query returns a list of classes for the projects analyzed. If you want to include the results for `builtin classes <http://docs.python.org/library/stdtypes.html>`__, which do not have any Python source code, show the non-source results.
|
||||
|
||||
Summary
|
||||
~~~~~~~
|
||||
|
||||
- `Object <https://help.semmle.com/qldoc/python/semmle/python/types/Object.qll/type.Object$Object.html>`__
|
||||
- `Value <https://help.semmle.com/qldoc/python/semmle/python/objects/ObjectAPI.qll/type.ObjectAPI$Value.html>`__
|
||||
|
||||
- ``ClassObject``
|
||||
- ``FunctionObject``
|
||||
- ``ModuleObject``
|
||||
- ``ClassValue``
|
||||
- ``CallableValue``
|
||||
- ``ModuleValue``
|
||||
|
||||
These classes are explained in more detail in :doc:`Tutorial: Points-to analysis and type inference <pointsto-type-infer>`.
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ The sink is defined by using a custom ``TaintTracking::Sink`` class.
|
|||
class UnsafeSink extends TaintTracking::Sink {
|
||||
|
||||
UnsafeSink() {
|
||||
exists(FunctionObject unsafe |
|
||||
exists(FunctionValue unsafe |
|
||||
unsafe.getName() = "unsafe" and
|
||||
unsafe.getACall().(CallNode).getAnArg() = this
|
||||
)
|
||||
|
@ -172,7 +172,7 @@ Thus, our example query becomes:
|
|||
class UnsafeSink extends TaintTracking::Sink {
|
||||
|
||||
UnsafeSink() {
|
||||
exists(FunctionObject unsafe |
|
||||
exists(FunctionValue unsafe |
|
||||
unsafe.getName() = "unsafe" and
|
||||
unsafe.getACall().(CallNode).getAnArg() = this
|
||||
)
|
||||
|
@ -255,4 +255,4 @@ What next?
|
|||
----------
|
||||
|
||||
- Experiment with the worked examples in the QL for Python tutorial topics: :doc:`Control flow <control-flow>`, and :doc:`Points-to analysis and type inference <pointsto-type-infer>`.
|
||||
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/QLLanguageSpecification.html>`__.
|
||||
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/QLLanguageSpecification.html>`__.
|
||||
|
|
Загрузка…
Ссылка в новой задаче