-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPauli.qll
36 lines (32 loc) · 1.06 KB
/
Pauli.qll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import python
import semmle.python.dataflow.new.DataFlow
import semmle.python.ApiGraphs
import qiskit.NoiseModel
class PauliString extends StrConst {
PauliString() {
// it can be used in a PauliError
exists(
PauliError pauliError
|
pauliError.getPauliString() = this
)
or
// it can be used in a Pauli object
exists(
DataFlow::CallCfgNode pauliObject
|
pauliObject = API::moduleImport("qiskit").getMember("circuit")
.getMember("QuantumCircuit").getMember("pauli").getACall()
or
// from qiskit.quantum_info import Pauli
pauliObject = API::moduleImport("qiskit").getMember("quantum_info")
.getMember("Pauli").getACall()
|
this = pauliObject.getArg(0).asCfgNode().getNode()
)
}
/** Check if the Pauli satisfy the regex ^[+-]?1?[ij]?[IXYZ]+$ */
predicate isValid() {
this.getText().regexpMatch("^[+-]?1?[ij]?[IXYZ]+$")
}
}