Skip to main content

LGTM

This Integration is part of the DevSecOps Pack.#

Supported versions

Supported Cortex XSOAR versions: 6.0.0 and later.

An Integration with LGTM API This integration was integrated and tested with version 1.0 of LGTM

Configure LGTM on Cortex XSOAR#

  1. Navigate to Settings > Integrations > Servers & Services.
  2. Search for LGTM.
  3. Click Add instance to create and configure a new integration instance.
ParameterDescriptionRequired
urlServer URL (e.g. https://lgtm.com/api/v1.0)True
api_keyAPI KeyTrue
insecureTrust any certificate (not secure)False
proxyUse system proxy settingsFalse
  1. Click Test to validate the URLs, token, and connection.

Commands#

You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook. After you successfully execute a command, a DBot message appears in the War Room with the command details.

lgtm-add-project#


Add a project to LGTM

Base Command#

lgtm-add-project

Input#

Argument NameDescriptionRequired
repositoryThe URL of the repository to analyze. LGTM tests this against the repository providers defined for the system. If it doesn't match any of them, the request fails.Required
languageOptional, a language code to specify which language to analyze. To request the analysis of more than one language, specify a query meter for each language. By default, LGTM tries to analyze all supported languages.Optional
modeThe analysis mode of the new project. When set to full all commits of the project are analyzed; when set to sparse the latest commit of the project is analyzed periodically; when set to upload, no automatic analysis is performed, instead externally-generated databases should be uploaded. For new projects the default value is full. The mode meter cannot be used to change the analysis mode of existing projects. Therefore, for existing projects, it should either be left blank or set to match the analysis mode of the project.Optional
commitRequired when mode=upload, specify the identifier of the commit used to generate the database.Optional
dateOptional when mode=upload, specify the date and time of the commit used to generate the database; defaults to the current time.Optional
worker-labelOptional, any labels required by workers to analyze this project. To specify more than one label, repeat the query meter.Optional

Context Output#

There is no context output for this command.

Command Example#

Human Readable Output#

lgtm-get-alerts#


Get detailed alert information

Base Command#

lgtm-get-alerts

Input#

Argument NameDescriptionRequired
analysis-idThe analysis identifier.Required
sarif-versionThe desired version of the SARIF format. Currently supported versions are 1.0.0, 2.0.0, and 2.1.0.Optional
excluded-filesSet true to include results in files that are excluded from the output by default. This includes results in test code and generated files. For more information, see File classification.Optional

Context Output#

PathTypeDescription
LGTM.alerts.runs.results.ruleIdUnknownLGTM Alerts by Rule ID
LGTM.alerts.runs.results.partialFingerprints.primaryLocationLineHashUnknownLGTM Alert location by line hash

Command Example#

!lgtm-get-alerts analysis-id=1977acc9cbeb31c5fb106de40600a365061506e9

Context Example#

{
"LGTM": {
"alerts": {
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"runs": [
{
"artifacts": [
{
"location": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
}
}
],
"columnKind": "unicodeCodePoints",
"properties": {
"semmle.formatSpecifier": "2.1.0",
"semmle.sourceLanguage": "python"
},
"results": [
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 70,
"startColumn": 23,
"startLine": 112
}
}
}
],
"message": {
"text": "Call to [function load_from_config](1) with too many arguments; should be no more than 1."
},
"partialFingerprints": {
"primaryLocationLineHash": "a8e1daf8b5008d1d:1",
"primaryLocationStartColumnFingerprint": "18"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "function load_from_config"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 28,
"startLine": 101
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/call/wrong-arguments",
"ruleIndex": 0
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 49,
"startColumn": 12,
"startLine": 113
}
}
}
],
"message": {
"text": "Call to [function load_from_config](1) with too many arguments; should be no more than 1."
},
"partialFingerprints": {
"primaryLocationLineHash": "5c8cfaabeac1e16d:1",
"primaryLocationStartColumnFingerprint": "7"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "function load_from_config"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 28,
"startLine": 101
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/call/wrong-arguments",
"ruleIndex": 0
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 19,
"startColumn": 5,
"startLine": 24
}
}
}
],
"message": {
"text": "This assignment to 'code_execution' is unnecessary as it is redefined [here](1) before this value is used."
},
"partialFingerprints": {
"primaryLocationLineHash": "8180e24b4613f9a2:1",
"primaryLocationStartColumnFingerprint": "4"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "here"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 19,
"startColumn": 5,
"startLine": 31
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/multiple-definition",
"ruleIndex": 1
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 13,
"startColumn": 9,
"startLine": 46
}
}
}
],
"message": {
"text": "This assignment to 'user' is unnecessary as it is redefined [here](1) before this value is used."
},
"partialFingerprints": {
"primaryLocationLineHash": "5358472308e96529:1",
"primaryLocationStartColumnFingerprint": "0"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "here"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 13,
"startColumn": 9,
"startLine": 50
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/multiple-definition",
"ruleIndex": 1
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 13,
"startColumn": 9,
"startLine": 50
}
}
}
],
"message": {
"text": "This assignment to 'user' is unnecessary as it is redefined [here](1) before this value is used."
},
"partialFingerprints": {
"primaryLocationLineHash": "1805a8f6fd5b76df:1",
"primaryLocationStartColumnFingerprint": "0"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "here"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 13,
"startColumn": 9,
"startLine": 54
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/multiple-definition",
"ruleIndex": 1
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 19,
"startColumn": 5,
"startLine": 223
}
}
}
],
"message": {
"text": "This assignment to 'send_encrypted' is unnecessary as it is redefined [here](1) before this value is used."
},
"partialFingerprints": {
"primaryLocationLineHash": "552c6bffbe6cb915:1",
"primaryLocationStartColumnFingerprint": "4"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "here"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 19,
"startColumn": 5,
"startLine": 230
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/multiple-definition",
"ruleIndex": 1
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 13,
"startColumn": 9,
"startLine": 54
}
}
}
],
"message": {
"text": "The value assigned to local variable 'user' is never used."
},
"partialFingerprints": {
"primaryLocationLineHash": "d37b5c11bd142430:1",
"primaryLocationStartColumnFingerprint": "0"
},
"ruleId": "com.lgtm/python-queries:py/unused-local-variable",
"ruleIndex": 2
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 9,
"startColumn": 5,
"startLine": 64
}
}
}
],
"message": {
"text": "The value assigned to local variable 'data' is never used."
},
"partialFingerprints": {
"primaryLocationLineHash": "b60374c7564cf3b5:1",
"primaryLocationStartColumnFingerprint": "0"
},
"ruleId": "com.lgtm/python-queries:py/unused-local-variable",
"ruleIndex": 2
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 9,
"startColumn": 5,
"startLine": 73
}
}
}
],
"message": {
"text": "The value assigned to local variable 'data' is never used."
},
"partialFingerprints": {
"primaryLocationLineHash": "269b1675deaafb50:1",
"primaryLocationStartColumnFingerprint": "0"
},
"ruleId": "com.lgtm/python-queries:py/unused-local-variable",
"ruleIndex": 2
},
{
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 9,
"startColumn": 5,
"startLine": 85
}
}
}
],
"message": {
"text": "The value assigned to local variable 'data' is never used."
},
"partialFingerprints": {
"primaryLocationLineHash": "c32d3d378ff25d1d:1",
"primaryLocationStartColumnFingerprint": "0"
},
"ruleId": "com.lgtm/python-queries:py/unused-local-variable",
"ruleIndex": 2
},
{
"codeFlows": [
{
"threadFlows": [
{
"locations": [
{
"location": {
"message": {
"text": "Step 1"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 44,
"startColumn": 16,
"startLine": 156
}
}
}
},
{
"location": {
"message": {
"text": "Step 2"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 41,
"startColumn": 33,
"startLine": 158
}
}
}
}
]
}
]
}
],
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 41,
"startColumn": 33,
"startLine": 158
}
}
}
],
"message": {
"text": "Sensitive data from [a request parameter containing a password](1) is stored here."
},
"partialFingerprints": {
"primaryLocationLineHash": "ba844552ea173e36:1",
"primaryLocationStartColumnFingerprint": "28"
},
"relatedLocations": [
{
"id": 1,
"message": {
"text": "a request parameter containing a password"
},
"physicalLocation": {
"artifactLocation": {
"index": 0,
"uri": "module1.py",
"uriBaseId": "%SRCROOT%"
},
"region": {
"endColumn": 44,
"startColumn": 16,
"startLine": 156
}
}
}
],
"ruleId": "com.lgtm/python-queries:py/clear-text-storage-sensitive-data",
"ruleIndex": 3
}
],
"tool": {
"driver": {
"name": "LGTM.com",
"organization": "Semmle",
"rules": [
{
"defaultConfiguration": {
"level": "error"
},
"fullDescription": {
"text": "Using too many or too few arguments in a call to a function will result in a TypeError at runtime."
},
"id": "com.lgtm/python-queries:py/call/wrong-arguments",
"name": "com.lgtm/python-queries:py/call/wrong-arguments",
"properties": {
"kind": "problem",
"precision": "very-high",
"problem.severity": "error",
"sub-severity": "low",
"tags": [
"reliability",
"correctness",
"external/cwe/cwe-685"
]
},
"shortDescription": {
"text": "Wrong number of arguments in a call"
}
},
{
"defaultConfiguration": {},
"fullDescription": {
"text": "Assignment to a variable occurs multiple times without any intermediate use of that variable"
},
"id": "com.lgtm/python-queries:py/multiple-definition",
"name": "com.lgtm/python-queries:py/multiple-definition",
"properties": {
"kind": "problem",
"precision": "very-high",
"problem.severity": "warning",
"sub-severity": "low",
"tags": [
"maintainability",
"useless-code",
"external/cwe/cwe-563"
]
},
"shortDescription": {
"text": "Variable defined multiple times"
}
},
{
"defaultConfiguration": {
"level": "note"
},
"fullDescription": {
"text": "Local variable is defined but not used"
},
"id": "com.lgtm/python-queries:py/unused-local-variable",
"name": "com.lgtm/python-queries:py/unused-local-variable",
"properties": {
"kind": "problem",
"precision": "very-high",
"problem.severity": "recommendation",
"sub-severity": "high",
"tags": [
"maintainability",
"useless-code",
"external/cwe/cwe-563"
]
},
"shortDescription": {
"text": "Unused local variable"
}
},
{
"defaultConfiguration": {
"level": "error"
},
"fullDescription": {
"text": "Sensitive information stored without encryption or hashing can expose it to an attacker."
},
"id": "com.lgtm/python-queries:py/clear-text-storage-sensitive-data",
"name": "com.lgtm/python-queries:py/clear-text-storage-sensitive-data",
"properties": {
"kind": "path-problem",
"precision": "high",
"problem.severity": "error",
"tags": [
"security",
"external/cwe/cwe-312",
"external/cwe/cwe-315",
"external/cwe/cwe-359"
]
},
"shortDescription": {
"text": "Clear-text storage of sensitive information"
}
}
],
"version": "1.26.0-SNAPSHOT"
}
}
}
],
"version": "2.1.0"
}
}
}

Human Readable Output#

Results#

$schemarunsversion
https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json{'tool': {'driver': {'name': 'LGTM.com', 'organization': 'Semmle', 'version': '1.26.0-SNAPSHOT', 'rules': [{'id': 'com.lgtm/python-queries:py/call/wrong-arguments', 'name': 'com.lgtm/python-queries:py/call/wrong-arguments', 'shortDescription': {'text': 'Wrong number of arguments in a call'}, 'fullDescription': {'text': 'Using too many or too few arguments in a call to a function will result in a TypeError at runtime.'}, 'defaultConfiguration': {'level': 'error'}, 'properties': {'tags': ['reliability', 'correctness', 'external/cwe/cwe-685'], 'kind': 'problem', 'precision': 'very-high', 'sub-severity': 'low', 'problem.severity': 'error'}}, {'id': 'com.lgtm/python-queries:py/multiple-definition', 'name': 'com.lgtm/python-queries:py/multiple-definition', 'shortDescription': {'text': 'Variable defined multiple times'}, 'fullDescription': {'text': 'Assignment to a variable occurs multiple times without any intermediate use of that variable'}, 'defaultConfiguration': {}, 'properties': {'tags': ['maintainability', 'useless-code', 'external/cwe/cwe-563'], 'kind': 'problem', 'precision': 'very-high', 'sub-severity': 'low', 'problem.severity': 'warning'}}, {'id': 'com.lgtm/python-queries:py/unused-local-variable', 'name': 'com.lgtm/python-queries:py/unused-local-variable', 'shortDescription': {'text': 'Unused local variable'}, 'fullDescription': {'text': 'Local variable is defined but not used'}, 'defaultConfiguration': {'level': 'note'}, 'properties': {'tags': ['maintainability', 'useless-code', 'external/cwe/cwe-563'], 'kind': 'problem', 'precision': 'very-high', 'sub-severity': 'high', 'problem.severity': 'recommendation'}}, {'id': 'com.lgtm/python-queries:py/clear-text-storage-sensitive-data', 'name': 'com.lgtm/python-queries:py/clear-text-storage-sensitive-data', 'shortDescription': {'text': 'Clear-text storage of sensitive information'}, 'fullDescription': {'text': 'Sensitive information stored without encryption or hashing can expose it to an attacker.'}, 'defaultConfiguration': {'level': 'error'}, 'properties': {'tags': ['security', 'external/cwe/cwe-312', 'external/cwe/cwe-315', 'external/cwe/cwe-359'], 'kind': 'path-problem', 'precision': 'high', 'problem.severity': 'error'}}]}}, 'artifacts': [{'location': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}}], 'results': [{'ruleId': 'com.lgtm/python-queries:py/call/wrong-arguments', 'ruleIndex': 0, 'message': {'text': 'Call to [function load_from_config](1) with too many arguments; should be no more than 1.'}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 112, 'startColumn': 23, 'endColumn': 70}}}], 'partialFingerprints': {'primaryLocationLineHash': 'a8e1daf8b5008d1d:1', 'primaryLocationStartColumnFingerprint': '18'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 101, 'endColumn': 28}}, 'message': {'text': 'function load_from_config'}}]}, {'ruleId': 'com.lgtm/python-queries:py/call/wrong-arguments', 'ruleIndex': 0, 'message': {'text': 'Call to [function load_from_config](1) with too many arguments; should be no more than 1.'}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 113, 'startColumn': 12, 'endColumn': 49}}}], 'partialFingerprints': {'primaryLocationLineHash': '5c8cfaabeac1e16d:1', 'primaryLocationStartColumnFingerprint': '7'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 101, 'endColumn': 28}}, 'message': {'text': 'function load_from_config'}}]}, {'ruleId': 'com.lgtm/python-queries:py/multiple-definition', 'ruleIndex': 1, 'message': {'text': "This assignment to 'code_execution' is unnecessary as it is redefined [here](1) before this value is used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 24, 'startColumn': 5, 'endColumn': 19}}}], 'partialFingerprints': {'primaryLocationLineHash': '8180e24b4613f9a2:1', 'primaryLocationStartColumnFingerprint': '4'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 31, 'startColumn': 5, 'endColumn': 19}}, 'message': {'text': 'here'}}]}, {'ruleId': 'com.lgtm/python-queries:py/multiple-definition', 'ruleIndex': 1, 'message': {'text': "This assignment to 'user' is unnecessary as it is redefined [here](1) before this value is used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 46, 'startColumn': 9, 'endColumn': 13}}}], 'partialFingerprints': {'primaryLocationLineHash': '5358472308e96529:1', 'primaryLocationStartColumnFingerprint': '0'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 50, 'startColumn': 9, 'endColumn': 13}}, 'message': {'text': 'here'}}]}, {'ruleId': 'com.lgtm/python-queries:py/multiple-definition', 'ruleIndex': 1, 'message': {'text': "This assignment to 'user' is unnecessary as it is redefined [here](1) before this value is used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 50, 'startColumn': 9, 'endColumn': 13}}}], 'partialFingerprints': {'primaryLocationLineHash': '1805a8f6fd5b76df:1', 'primaryLocationStartColumnFingerprint': '0'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 54, 'startColumn': 9, 'endColumn': 13}}, 'message': {'text': 'here'}}]}, {'ruleId': 'com.lgtm/python-queries:py/multiple-definition', 'ruleIndex': 1, 'message': {'text': "This assignment to 'send_encrypted' is unnecessary as it is redefined [here](1) before this value is used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 223, 'startColumn': 5, 'endColumn': 19}}}], 'partialFingerprints': {'primaryLocationLineHash': '552c6bffbe6cb915:1', 'primaryLocationStartColumnFingerprint': '4'}, 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 230, 'startColumn': 5, 'endColumn': 19}}, 'message': {'text': 'here'}}]}, {'ruleId': 'com.lgtm/python-queries:py/unused-local-variable', 'ruleIndex': 2, 'message': {'text': "The value assigned to local variable 'user' is never used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 54, 'startColumn': 9, 'endColumn': 13}}}], 'partialFingerprints': {'primaryLocationLineHash': 'd37b5c11bd142430:1', 'primaryLocationStartColumnFingerprint': '0'}}, {'ruleId': 'com.lgtm/python-queries:py/unused-local-variable', 'ruleIndex': 2, 'message': {'text': "The value assigned to local variable 'data' is never used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 64, 'startColumn': 5, 'endColumn': 9}}}], 'partialFingerprints': {'primaryLocationLineHash': 'b60374c7564cf3b5:1', 'primaryLocationStartColumnFingerprint': '0'}}, {'ruleId': 'com.lgtm/python-queries:py/unused-local-variable', 'ruleIndex': 2, 'message': {'text': "The value assigned to local variable 'data' is never used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 73, 'startColumn': 5, 'endColumn': 9}}}], 'partialFingerprints': {'primaryLocationLineHash': '269b1675deaafb50:1', 'primaryLocationStartColumnFingerprint': '0'}}, {'ruleId': 'com.lgtm/python-queries:py/unused-local-variable', 'ruleIndex': 2, 'message': {'text': "The value assigned to local variable 'data' is never used."}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 85, 'startColumn': 5, 'endColumn': 9}}}], 'partialFingerprints': {'primaryLocationLineHash': 'c32d3d378ff25d1d:1', 'primaryLocationStartColumnFingerprint': '0'}}, {'ruleId': 'com.lgtm/python-queries:py/clear-text-storage-sensitive-data', 'ruleIndex': 3, 'message': {'text': 'Sensitive data from [a request parameter containing a password](1) is stored here.'}, 'locations': [{'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 158, 'startColumn': 33, 'endColumn': 41}}}], 'partialFingerprints': {'primaryLocationLineHash': 'ba844552ea173e36:1', 'primaryLocationStartColumnFingerprint': '28'}, 'codeFlows': [{'threadFlows': [{'locations': [{'location': {'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 156, 'startColumn': 16, 'endColumn': 44}}, 'message': {'text': 'Step 1'}}}, {'location': {'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 158, 'startColumn': 33, 'endColumn': 41}}, 'message': {'text': 'Step 2'}}}]}]}], 'relatedLocations': [{'id': 1, 'physicalLocation': {'artifactLocation': {'uri': 'module1.py', 'uriBaseId': '%SRCROOT%', 'index': 0}, 'region': {'startLine': 156, 'startColumn': 16, 'endColumn': 44}}, 'message': {'text': 'a request parameter containing a password'}}]}], 'columnKind': 'unicodeCodePoints', 'properties': {'semmle.formatSpecifier': '2.1.0', 'semmle.sourceLanguage': 'python'}}2.1.0

lgtm-get-analysis#


Get analysis summary

Base Command#

lgtm-get-analysis

Input#

Argument NameDescriptionRequired
analysis-idThe analysis identifier.Required

Context Output#

PathTypeDescription
LGTM.analysis_summary.idStringThe analysis identifier.
LGTM.analysis_summary.commit-idStringThe commit identifier. The commit identifier is included only if the same commit was successfully analyzed for all languages. A detailed eakdown of which commit was analyzed for each language is provided in the `languages` property.
LGTM.analysis_summary.languages.languageStringThe short name for the language.
LGTM.analysis_summary.languages.statusStringThe status of the analysis of this language.
LGTM.analysis_summary.languages.alertsNumberThe number of alerts for this language.
LGTM.analysis_summary.languages.linesNumberThe number of lines of code for this language.
LGTM.analysis_summary.languages.commit-idStringThe latest successfully analyzed commit for the language. All statistics refer to this commit.
LGTM.analysis_summary.languages.commit-dateStringThe time of the commit.
LGTM.analysis_summary.languages.analysis-dateStringThe time the commit was analyzed.
LGTM.analysis_summary.log-urlStringA page on LGTM to view the logs for this analysis.
LGTM.analysis_summary.results-urlStringA page on LGTM to view the results of this analysis.

Command Example#

!lgtm-get-analysis analysis-id=c8996fdd9968066cd410eda9deffdfdcca550e14

Context Example#

{
"LGTM": {
"analysis_summary": {
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"id": "c8996fdd9968066cd410eda9deffdfdcca550e14",
"languages": [
{
"alerts": 5,
"analysis-date": "2020-06-03T10:09:59.802+0000",
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"language": "python",
"lines": 87,
"status": "success"
}
],
"log-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14",
"project": {
"id": 1511925128331,
"name": "my-tradingbot/scanner",
"url": "https://lgtm.com/projects/g/my-tradingbot/scanner",
"url-identifier": "g/my-tradingbot/scanner"
},
"results-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14/files"
}
}
}

Human Readable Output#

Results#

commit-ididlanguageslog-urlprojectresults-url
b1b136e071533d78053be506d32f79417651727dc8996fdd9968066cd410eda9deffdfdcca550e14{'language': 'python', 'status': 'success', 'alerts': 5, 'lines': 87, 'commit-id': 'b1b136e071533d78053be506d32f79417651727d', 'analysis-date': '2020-06-03T10:09:59.802+0000'}https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14id: 1511925128331
url-identifier: g/my-tradingbot/scanner
name: my-tradingbot/scanner
url: https://lgtm.com/projects/g/my-tradingbot/scanner
https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14/files

lgtm-get-analysis-for-commit#


Get analysis summary for a specific commit

Base Command#

lgtm-get-analysis-for-commit

Input#

Argument NameDescriptionRequired
project-idThe numeric project identifier.Required
commit-idThe identifier of a specific commit. Alternatively, use latest for the most recent analyzed commit.Required

Context Output#

PathTypeDescription
LGTM.analysis_summary.idStringThe analysis identifier.
LGTM.analysis_summary.commit-idStringThe commit identifier. The commit identifier is included only if the same commit was successfully analyzed for all languages. A detailed eakdown of which commit was analyzed for each language is provided in the `languages` property.
LGTM.analysis_summary.languages.languageStringThe short name for the language.
LGTM.analysis_summary.languages.statusStringThe status of the analysis of this language.
LGTM.analysis_summary.languages.alertsNumberThe number of alerts for this language.
LGTM.analysis_summary.languages.linesNumberThe number of lines of code for this language.
LGTM.analysis_summary.languages.commit-idStringThe latest successfully analyzed commit for the language. All statistics refer to this commit.
LGTM.analysis_summary.languages.commit-dateStringThe time of the commit.
LGTM.analysis_summary.languages.analysis-dateStringThe time the commit was analyzed.
LGTM.analysis_summary.log-urlStringA page on LGTM to view the logs for this analysis.
LGTM.analysis_summary.results-urlStringA page on LGTM to view the results of this analysis.

Command Example#

!lgtm-get-analysis-for-commit commit-id=b1b136e071533d78053be506d32f79417651727d project-id=1511925128331

Context Example#

{
"LGTM": {
"analysis_summary": {
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"id": "c8996fdd9968066cd410eda9deffdfdcca550e14",
"languages": [
{
"alerts": 5,
"analysis-date": "2020-06-03T10:09:59.802+0000",
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"language": "python",
"lines": 87,
"status": "success"
}
],
"log-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14",
"project": {
"id": 1511925128331,
"name": "my-tradingbot/scanner",
"url": "https://lgtm.com/projects/g/my-tradingbot/scanner",
"url-identifier": "g/my-tradingbot/scanner"
},
"results-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14/files"
}
}
}

Human Readable Output#

Results#

commit-ididlanguageslog-urlprojectresults-url
b1b136e071533d78053be506d32f79417651727dc8996fdd9968066cd410eda9deffdfdcca550e14{'language': 'python', 'status': 'success', 'alerts': 5, 'lines': 87, 'commit-id': 'b1b136e071533d78053be506d32f79417651727d', 'analysis-date': '2020-06-03T10:09:59.802+0000'}https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14id: 1511925128331
url-identifier: g/my-tradingbot/scanner
name: my-tradingbot/scanner
url: https://lgtm.com/projects/g/my-tradingbot/scanner
https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/c8996fdd9968066cd410eda9deffdfdcca550e14/files

lgtm-get-code-review#


Get results of code review

Base Command#

lgtm-get-code-review

Input#

Argument NameDescriptionRequired
review-idThe identifier for the review (from the task-result-url).Required

Context Output#

PathTypeDescription
LGTM.code_review_result.idStringThe identifier for the review.
LGTM.code_review_result.results-urlStringA page on LGTM to view the status and results of this code review.
LGTM.code_review_result.statusStringThe status of the code review.
LGTM.code_review_result.status-messageStringA summary of the current status of the code review.
LGTM.code_review_result.languages.languageStringThe language analyzed.
LGTM.code_review_result.languages.statusStringThe status for analysis of this language.
LGTM.code_review_result.languages.status-messageStringThe current state of analysis of this langauge. When available, a summary of analysis results.
LGTM.code_review_result.languages.newNumberThe total number of alerts introduced by the patch for this language.
LGTM.code_review_result.languages.fixedNumberThe total number of alerts fixed by the patch for this language.
LGTM.code_review_result.languages.alerts.newNumberThe number of alerts introduced by the patch for this query.
LGTM.code_review_result.languages.alerts.fixedNumberThe number of alerts fixed by the patch for this query.

Command Example#

!lgtm-get-code-review review-id=525d2cd0df76e6ba1e5a47c920b61cacb8e4068e

Context Example#

{
"LGTM": {
"code_review_result": {
"id": "525d2cd0df76e6ba1e5a47c920b61cacb8e4068e",
"languages": [
{
"alerts": [
{
"fixed": 0,
"new": 0,
"query": {
"id": 9980089,
"language": "python",
"name": "Statement has no effect",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/ineffectual-statement",
"name": "Statement has no effect",
"severity": "recommendation",
"tags": [
"maintainability",
"useless-code",
"external/cwe/cwe-561"
]
},
"url": "https://lgtm.com/rules/9980089"
}
},
{
"fixed": 1,
"new": 0,
"query": {
"id": 1510006386081,
"language": "python",
"name": "Clear-text storage of sensitive information",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/clear-text-storage-sensitive-data",
"name": "Clear-text storage of sensitive information",
"severity": "error",
"tags": [
"security",
"external/cwe/cwe-312",
"external/cwe/cwe-315",
"external/cwe/cwe-359"
]
},
"url": "https://lgtm.com/rules/1510006386081"
}
},
{
"fixed": 4,
"new": 0,
"query": {
"id": 6780086,
"language": "python",
"name": "Unused local variable",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/unused-local-variable",
"name": "Unused local variable",
"severity": "recommendation",
"tags": [
"maintainability",
"useless-code",
"external/cwe/cwe-563"
]
},
"url": "https://lgtm.com/rules/6780086"
}
},
{
"fixed": 4,
"new": 0,
"query": {
"id": 1800095,
"language": "python",
"name": "Variable defined multiple times",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/multiple-definition",
"name": "Variable defined multiple times",
"severity": "warning",
"tags": [
"maintainability",
"useless-code",
"external/cwe/cwe-563"
]
},
"url": "https://lgtm.com/rules/1800095"
}
},
{
"fixed": 0,
"new": 0,
"query": {
"id": 3960089,
"language": "python",
"name": "Explicit returns mixed with implicit (fall through) returns",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/mixed-returns",
"name": "Explicit returns mixed with implicit (fall through) returns",
"severity": "recommendation",
"tags": [
"reliability",
"maintainability"
]
},
"url": "https://lgtm.com/rules/3960089"
}
},
{
"fixed": 2,
"new": 0,
"query": {
"id": 1780094,
"language": "python",
"name": "Wrong number of arguments in a call",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/call/wrong-arguments",
"name": "Wrong number of arguments in a call",
"severity": "error",
"tags": [
"reliability",
"correctness",
"external/cwe/cwe-685"
]
},
"url": "https://lgtm.com/rules/1780094"
}
},
{
"fixed": 0,
"new": 0,
"query": {
"id": 10030095,
"language": "python",
"name": "File is not always closed",
"pack": "com.lgtm/python-queries",
"properties": {
"id": "py/file-not-closed",
"name": "File is not always closed",
"severity": "warning",
"tags": [
"efficiency",
"correctness",
"resources",
"external/cwe/cwe-772"
]
},
"url": "https://lgtm.com/rules/10030095"
}
}
],
"fixed": 11,
"language": "python",
"new": 0,
"status": "success",
"status-message": "11 fixed alerts"
}
],
"results-url": "https://lgtm.com/projects/g/my-devsecops/moon/rev/pr-525d2cd0df76e6ba1e5a47c920b61cacb8e4068e",
"status": "success",
"status-message": "Analysis succeeded"
}
}
}

Human Readable Output#

Results#

idlanguagesresults-urlstatusstatus-message
525d2cd0df76e6ba1e5a47c920b61cacb8e4068e{'language': 'python', 'status': 'success', 'status-message': '11 fixed alerts', 'new': 0, 'fixed': 11, 'alerts': [{'query': {'id': 9980089, 'pack': 'com.lgtm/python-queries', 'name': 'Statement has no effect', 'language': 'python', 'properties': {'id': 'py/ineffectual-statement', 'name': 'Statement has no effect', 'severity': 'recommendation', 'tags': ['maintainability', 'useless-code', 'external/cwe/cwe-561']}, 'url': 'https://lgtm.com/rules/9980089'}, 'new': 0, 'fixed': 0}, {'query': {'id': 1510006386081, 'pack': 'com.lgtm/python-queries', 'name': 'Clear-text storage of sensitive information', 'language': 'python', 'properties': {'id': 'py/clear-text-storage-sensitive-data', 'name': 'Clear-text storage of sensitive information', 'severity': 'error', 'tags': ['security', 'external/cwe/cwe-312', 'external/cwe/cwe-315', 'external/cwe/cwe-359']}, 'url': 'https://lgtm.com/rules/1510006386081'}, 'new': 0, 'fixed': 1}, {'query': {'id': 6780086, 'pack': 'com.lgtm/python-queries', 'name': 'Unused local variable', 'language': 'python', 'properties': {'id': 'py/unused-local-variable', 'name': 'Unused local variable', 'severity': 'recommendation', 'tags': ['maintainability', 'useless-code', 'external/cwe/cwe-563']}, 'url': 'https://lgtm.com/rules/6780086'}, 'new': 0, 'fixed': 4}, {'query': {'id': 1800095, 'pack': 'com.lgtm/python-queries', 'name': 'Variable defined multiple times', 'language': 'python', 'properties': {'id': 'py/multiple-definition', 'name': 'Variable defined multiple times', 'severity': 'warning', 'tags': ['maintainability', 'useless-code', 'external/cwe/cwe-563']}, 'url': 'https://lgtm.com/rules/1800095'}, 'new': 0, 'fixed': 4}, {'query': {'id': 3960089, 'pack': 'com.lgtm/python-queries', 'name': 'Explicit returns mixed with implicit (fall through) returns', 'language': 'python', 'properties': {'id': 'py/mixed-returns', 'name': 'Explicit returns mixed with implicit (fall through) returns', 'severity': 'recommendation', 'tags': ['reliability', 'maintainability']}, 'url': 'https://lgtm.com/rules/3960089'}, 'new': 0, 'fixed': 0}, {'query': {'id': 1780094, 'pack': 'com.lgtm/python-queries', 'name': 'Wrong number of arguments in a call', 'language': 'python', 'properties': {'id': 'py/call/wrong-arguments', 'name': 'Wrong number of arguments in a call', 'severity': 'error', 'tags': ['reliability', 'correctness', 'external/cwe/cwe-685']}, 'url': 'https://lgtm.com/rules/1780094'}, 'new': 0, 'fixed': 2}, {'query': {'id': 10030095, 'pack': 'com.lgtm/python-queries', 'name': 'File is not always closed', 'language': 'python', 'properties': {'id': 'py/file-not-closed', 'name': 'File is not always closed', 'severity': 'warning', 'tags': ['efficiency', 'correctness', 'resources', 'external/cwe/cwe-772']}, 'url': 'https://lgtm.com/rules/10030095'}, 'new': 0, 'fixed': 0}]}https://lgtm.com/projects/g/my-devsecops/moon/rev/pr-525d2cd0df76e6ba1e5a47c920b61cacb8e4068esuccessAnalysis succeeded

lgtm-get-project#


Get project by numeric identifier

Base Command#

lgtm-get-project

Input#

Argument NameDescriptionRequired
project-idThe numeric project identifierRequired

Context Output#

PathTypeDescription
LGTM.project_details.languages.gradeStringThe grade of the code for this language.
LGTM.project_details.idUnknownLGTM Project id
LGTM.project_details.nameUnknownLGTM Project name

Command Example#

!lgtm-get-project project-id=1512319787549

Context Example#

{
"LGTM": {
"project_details": {
"id": 1512319787549,
"languages": [
{
"alerts": 11,
"analysis-date": "2020-10-28T22:12:58.491+0000",
"commit-date": "2020-09-09T14:53:17.000+0000",
"commit-id": "39eb3dc0c7e86d0b943df1be922b173068010bf5",
"grade": "E",
"language": "python",
"lines": 127,
"status": "success"
}
],
"name": "my-devsecops/moon",
"url": "https://lgtm.com/projects/g/my-devsecops/moon",
"url-identifier": "g/my-devsecops/moon"
}
}
}

Human Readable Output#

Results#

idlanguagesnameurlurl-identifier
1512319787549{'language': 'python', 'status': 'success', 'alerts': 11, 'lines': 127, 'commit-id': '39eb3dc0c7e86d0b943df1be922b173068010bf5', 'commit-date': '2020-09-09T14:53:17.000+0000', 'analysis-date': '2020-10-28T22:12:58.491+0000', 'grade': 'E'}my-devsecops/moonhttps://lgtm.com/projects/g/my-devsecops/moong/my-devsecops/moon

lgtm-get-project-by-url-identifier#


Get project by URL identifier

Base Command#

lgtm-get-project-by-url-identifier

Input#

Argument NameDescriptionRequired
providerThe first part of the URL identifier of a project, which represents the repository host.Required
orgThe second part of the URL identifier of a project, the organization.Required
nameThe third part of the URL identifier of a project, the repository name.Required

Context Output#

PathTypeDescription
LGTM.project_details.languages.gradeStringThe grade of the code for this language.
LGTM.project_details.idUnknownLGTM Project id
LGTM.project_details.nameUnknownLGTM Project name

Command Example#

!lgtm-get-project-by-url-identifier name=moon org=my-devsecops provider=g

Context Example#

{
"LGTM": {
"project_details": {
"id": 1512319787549,
"languages": [
{
"alerts": 11,
"analysis-date": "2020-10-28T22:12:58.491+0000",
"commit-date": "2020-09-09T14:53:17.000+0000",
"commit-id": "39eb3dc0c7e86d0b943df1be922b173068010bf5",
"grade": "E",
"language": "python",
"lines": 127,
"status": "success"
}
],
"name": "my-devsecops/moon",
"url": "https://lgtm.com/projects/g/my-devsecops/moon",
"url-identifier": "g/my-devsecops/moon"
}
}
}

Human Readable Output#

Results#

idlanguagesnameurlurl-identifier
1512319787549{'language': 'python', 'status': 'success', 'alerts': 11, 'lines': 127, 'commit-id': '39eb3dc0c7e86d0b943df1be922b173068010bf5', 'commit-date': '2020-09-09T14:53:17.000+0000', 'analysis-date': '2020-10-28T22:12:58.491+0000', 'grade': 'E'}my-devsecops/moonhttps://lgtm.com/projects/g/my-devsecops/moong/my-devsecops/moon

lgtm-get-project-config#


Get configuration for a project identified by numeric identifier

Base Command#

lgtm-get-project-config

Input#

Argument NameDescriptionRequired
project-idThe numeric project identifierRequired
sourceThe type of project configuration to retrieve. If this meter isn't specified, the request retrieves the effective configuration. That is, the configuration that is actually applied to the project, which may be from: the repository the administrator-set, project configuration the global configuration. If you do specify this value, it must be one of: repository to retrieve the configuration specified by a YAML file in the repository. A 404 status is returned if there is no repository configuration. administrator to retrieve the administrator-set, project configuration. A 404 status is returned if there is no administrator configuration.Optional

Context Output#

There is no context output for this command.

Command Example#

!lgtm-get-project-config project-id="1511896439667"

Context Example#

{
"LGTM": {
"config": "path_classifiers:\n test: \"**/*_test.py\"\nqueries:\n- exclude: \"*\"\n- include:\n tags: \"security\"\n"
}
}

Human Readable Output#

Project Config#

Config
path_classifiers:
test: "*/_test.py"
queries:
- exclude: "*"
- include:
tags: "security"

lgtm-get-projects#


List projects

Base Command#

lgtm-get-projects

Input#

Argument NameDescriptionRequired
limitThe maximum number of projects to return in each response (1-100).Optional
startAn opaque identifier generated by the API.Optional

Context Output#

PathTypeDescription
LGTM.project-list.data.idNumberThe numeric identifier of the project.
LGTM.project-list.data.url-identifierStringThe URL identifier of the project.
LGTM.project-list.data.nameStringThe display name of the project.
LGTM.project-list.data.urlStringThe full URL of the project on LGTM.
LGTM.project-list.nextPageUrlStringThe URL to retrieve the next page of projects. Omitted if there is no next page.

Command Example#

!lgtm-get-projects limit=10

Context Example#

{
"LGTM": {
"project_list": {
"data": [
{
"id": 890003,
"name": "FountainJS/fountain-generator",
"url": "https://lgtm.com/projects/g/FountainJS/fountain-generator",
"url-identifier": "g/FountainJS/fountain-generator"
},
{
"id": 890022,
"name": "d3/d3-interpolate",
"url": "https://lgtm.com/projects/g/d3/d3-interpolate",
"url-identifier": "g/d3/d3-interpolate"
},
{
"id": 890042,
"name": "BanManagement/BanManager",
"url": "https://lgtm.com/projects/g/BanManagement/BanManager",
"url-identifier": "g/BanManagement/BanManager"
},
{
"id": 890045,
"name": "pull-stream/stream-to-pull-stream",
"url": "https://lgtm.com/projects/g/pull-stream/stream-to-pull-stream",
"url-identifier": "g/pull-stream/stream-to-pull-stream"
},
{
"id": 890048,
"name": "scijs/save-pixels",
"url": "https://lgtm.com/projects/g/scijs/save-pixels",
"url-identifier": "g/scijs/save-pixels"
},
{
"id": 890053,
"name": "forge/roaster",
"url": "https://lgtm.com/projects/g/forge/roaster",
"url-identifier": "g/forge/roaster"
},
{
"id": 890066,
"name": "puleos/object-hash",
"url": "https://lgtm.com/projects/g/puleos/object-hash",
"url-identifier": "g/puleos/object-hash"
},
{
"id": 890070,
"name": "TooTallNate/plist.js",
"url": "https://lgtm.com/projects/g/TooTallNate/plist.js",
"url-identifier": "g/TooTallNate/plist.js"
},
{
"id": 890073,
"name": "automatictester/lightning",
"url": "https://lgtm.com/projects/g/automatictester/lightning",
"url-identifier": "g/automatictester/lightning"
},
{
"id": 890076,
"name": "fjakobs/async.js",
"url": "https://lgtm.com/projects/g/fjakobs/async.js",
"url-identifier": "g/fjakobs/async.js"
}
],
"nextPageUrl": "https://lgtm.com/api/v1.0/projects?limit=10&start=AfyWmuiCRajZNPY1kkCBgpu1T2dXj1Nec9-hHV2I0Lmb4g2rUPgqvfkH9uaDhzNA3OUoI5xkAvNfd9mIMNNoHZQ-W4BHdNL6fshdYcZXUwQIzFxnzQszrWgD-o4gYW1nEg"
}
}
}

Human Readable Output#

Results#

datanextPageUrl
{'id': 890003, 'url-identifier': 'g/FountainJS/fountain-generator', 'name': 'FountainJS/fountain-generator', 'url': 'https://lgtm.com/projects/g/FountainJS/fountain-generator'},
{'id': 890022, 'url-identifier': 'g/d3/d3-interpolate', 'name': 'd3/d3-interpolate', 'url': 'https://lgtm.com/projects/g/d3/d3-interpolate'},
{'id': 890042, 'url-identifier': 'g/BanManagement/BanManager', 'name': 'BanManagement/BanManager', 'url': 'https://lgtm.com/projects/g/BanManagement/BanManager'},
{'id': 890045, 'url-identifier': 'g/pull-stream/stream-to-pull-stream', 'name': 'pull-stream/stream-to-pull-stream', 'url': 'https://lgtm.com/projects/g/pull-stream/stream-to-pull-stream'},
{'id': 890048, 'url-identifier': 'g/scijs/save-pixels', 'name': 'scijs/save-pixels', 'url': 'https://lgtm.com/projects/g/scijs/save-pixels'},
{'id': 890053, 'url-identifier': 'g/forge/roaster', 'name': 'forge/roaster', 'url': 'https://lgtm.com/projects/g/forge/roaster'},
{'id': 890066, 'url-identifier': 'g/puleos/object-hash', 'name': 'puleos/object-hash', 'url': 'https://lgtm.com/projects/g/puleos/object-hash'},
{'id': 890070, 'url-identifier': 'g/TooTallNate/plist.js', 'name': 'TooTallNate/plist.js', 'url': 'https://lgtm.com/projects/g/TooTallNate/plist.js'},
{'id': 890073, 'url-identifier': 'g/automatictester/lightning', 'name': 'automatictester/lightning', 'url': 'https://lgtm.com/projects/g/automatictester/lightning'},
{'id': 890076, 'url-identifier': 'g/fjakobs/async.js', 'name': 'fjakobs/async.js', 'url': 'https://lgtm.com/projects/g/fjakobs/async.js'}
https://lgtm.com/api/v1.0/projects?limit=10&start=AfyWmuiCRajZNPY1kkCBgpu1T2dXj1Nec9-hHV2I0Lmb4g2rUPgqvfkH9uaDhzNA3OUoI5xkAvNfd9mIMNNoHZQ-W4BHdNL6fshdYcZXUwQIzFxnzQszrWgD-o4gYW1nEg

lgtm-get-version#


Version information

Base Command#

lgtm-get-version

Input#

There are no input arguments for this command.

Context Output#

PathTypeDescription
LGTM.version.apiVersionStringThe version number of the API.

Command Example#

!lgtm-get-version

Context Example#

{
"LGTM": {
"version": {
"apiVersion": "1.0"
}
}
}

Human Readable Output#

Results#

apiVersion
1.0

lgtm-request-analysis#


Run analysis of a specific commit

Base Command#

lgtm-request-analysis

Input#

Argument NameDescriptionRequired
project-idThe numeric project identifier.Required
commitThe identifier of the commit to analyze.Required
languageThe language codes of the languages to analyze. For a list of available languages, see Supported languages. To specify more than one language, this meter can be repeated. If no language is specified, all the project's languages will be analyzed.Optional

Context Output#

PathTypeDescription
LGTM.analysis.idUnknownLGTM request id
LGTM.analysis.statusUnknownLGTM analysis status
LGTM.analysis_request.task-result.idUnknownLGTM analysis task id
LGTM.analysis_request.task-result.commit-idUnknownLGTM analysis commit id

Command Example#

!lgtm-request-analysis commit=b1b136e071533d78053be506d32f79417651727d project-id=1511925128331 language=python

Context Example#

{
"LGTM": {
"analysis_request": {
"id": 1512897038814,
"status": "done",
"task-result": {
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"id": "ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95",
"languages": [
{
"alerts": 5,
"analysis-date": "2020-11-04T07:37:31.324+0000",
"commit-date": "2020-05-31T14:33:52.000+0000",
"commit-id": "b1b136e071533d78053be506d32f79417651727d",
"language": "python",
"lines": 87,
"status": "success"
}
],
"log-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95",
"project": {
"id": 1511925128331,
"name": "my-tradingbot/scanner",
"url": "https://lgtm.com/projects/g/my-tradingbot/scanner",
"url-identifier": "g/my-tradingbot/scanner"
},
"results-url": "https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95/files"
},
"task-result-url": "https://lgtm.com/api/v1.0/analyses/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95",
"task-type": "analysis"
}
}
}

Human Readable Output#

Results#

idstatustask-resulttask-result-urltask-type
1512897038814doneid: ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95
project: {"id": 1511925128331, "url-identifier": "g/my-tradingbot/scanner", "name": "my-tradingbot/scanner", "url": "https://lgtm.com/projects/g/my-tradingbot/scanner"}
commit-id: b1b136e071533d78053be506d32f79417651727d
languages: {'language': 'python', 'status': 'success', 'alerts': 5, 'lines': 87, 'commit-id': 'b1b136e071533d78053be506d32f79417651727d', 'commit-date': '2020-05-31T14:33:52.000+0000', 'analysis-date': '2020-11-04T07:37:31.324+0000'}
log-url: https://lgtm.com/projects/g/my-tradingbot/scanner/logs/analysis/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95
results-url: https://lgtm.com/projects/g/my-tradingbot/scanner/analysis/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95/files
https://lgtm.com/api/v1.0/analyses/ef0e7bd0421cb2cc2e9cb7ab5ce3cba109ee2a95analysis

lgtm-request-review#


Run code review for a patch

Base Command#

lgtm-request-review

Input#

Argument NameDescriptionRequired
project-idThe numeric project identifier.Required
baseThe identifier for the base commit.Required
external-idYour reference number for the code review.Required
callback-urlThe callback URL for LGTM to post to on completion of the review. When the code review is complete, the API sends an HTTP POST request to the callback URL with the result of the code review in the request body. The code review results in the request body are identical to the results accessed through the /codereviews/{review-id} end-point. If you specify a callback-secret, the request also includes an x-lgtm-signature header with a digital signature of the request's contents.Optional
callback-secretThe callback-secret is used to compute a signature which is included in the x-lgtm-signature header of the callback response. The receiver of the callback can check the validity of the response by computing the signature using HMAC-SHA1 and verifying that it matches the x-lgtm-signature header value. The HMAC algorithm requires byte sequences as inputs for both the secret and the message. The callback secret string must be converted to bytes using UTF-8 encoding. The response body should ideally be read as a plain byte sequence. Conversion to, for example a JSON object, and back to a byte sequence might change the formatting, and would invalidate the signature.Optional
patch-entry-idEntry ID of the Patch File , you can use git diff --binary to generate patch fileRequired

Context Output#

PathTypeDescription
LGTM.code_review_request.idUnknownLGTM Code Review request id
LGTM.code_review_request.statusUnknownLGTM Code Review request status
LGTM.code_review_request.task-result.idUnknownLGTM Code Review request task id

Command Example#

!lgtm-request-review project-id=1512319787549 base=405fc6ea44910177f48db9b2eb6839efb4211743 external-id=49 patch-entry-id=478@ed5c5f6c-726a-4e62-85dc-8b1aad179194

Context Example#

{
"LGTM": {
"code_review_request": {
"id": 1512842530470,
"status": "pending",
"task-result": {
"id": "cccab75368f5e896c17f5155f759bad72fdb6adf",
"languages": [
{
"alerts": [],
"fixed": 0,
"language": "python",
"new": 0,
"status": "pending",
"status-message": "Starting up"
}
],
"results-url": "https://lgtm.com/projects/g/my-devsecops/moon/rev/pr-cccab75368f5e896c17f5155f759bad72fdb6adf",
"status": "pending",
"status-message": "Starting up"
},
"task-result-url": "https://lgtm.com/api/v1.0/codereviews/cccab75368f5e896c17f5155f759bad72fdb6adf",
"task-type": "codereview"
}
}
}

Human Readable Output#

Results#

idstatustask-resulttask-result-urltask-type
1512842530470pendingid: cccab75368f5e896c17f5155f759bad72fdb6adf
results-url: https://lgtm.com/projects/g/my-devsecops/moon/rev/pr-cccab75368f5e896c17f5155f759bad72fdb6adf
status: pending
status-message: Starting up
languages: {'language': 'python', 'status': 'pending', 'status-message': 'Starting up', 'new': 0, 'fixed': 0, 'alerts': []}
https://lgtm.com/api/v1.0/codereviews/cccab75368f5e896c17f5155f759bad72fdb6adfcodereview

lgtm-create-query-job#


Run a CodeQL query on one or more projects

Base Command#

lgtm-create-query-job

Input#

Argument NameDescriptionRequired
languageThe language you want to analyze.Required
project-idThe identifier of the project to analyze. Either project-id or projects-list must be specified.Required
query-listThe CodeQL query stored in an XSOAR listRequired

Context Output#

PathTypeDescription
LGTM.Queries.task-result.idUnknownQuery ID

Command Example#

!lgtm-create-query-job language=python project-id=1511896439667 query-list=${lists.CodeQL-Queries-SQL_Injection}

Context Example#

{
"LGTM": {
"queryjob": {
"id": 1512871744413,
"status": "pending",
"task-result": {
"id": "1877941903313451628",
"result-url": "https://lgtm.com/query/1877941903313451628",
"stats": {
"failed": 0,
"pending": 0,
"success-with-result": 0,
"success-without-result": 0,
"successful": 0
}
},
"task-result-url": "https://lgtm.com/api/v1.0/queryjobs/1877941903313451628",
"task-type": "queryjob"
}
}
}

Human Readable Output#

Results#

idstatustask-resulttask-result-urltask-type
1512871744413pendingid: 1877941903313451628
stats: {"successful": 0, "success-with-result": 0, "success-without-result": 0, "failed": 0, "pending": 0}
result-url: https://lgtm.com/query/1877941903313451628
https://lgtm.com/api/v1.0/queryjobs/1877941903313451628queryjob

lgtm-get-query-job#


Get the status of a query job

Base Command#

lgtm-get-query-job

Input#

Argument NameDescriptionRequired
queryjob-idThe identifier of the query job, from the task-result given in the response to the initial POST /queryjobs request.Required

Context Output#

PathTypeDescription
LGTM.queryjob.idStringThe identifier for the QueryJob.

Command Example#

!lgtm-get-query-job queryjob-id=2651230846634222938

Context Example#

{
"LGTM": {
"queryjob": {
"id": "2651230846634222938",
"result-url": "https://lgtm.com/query/2651230846634222938",
"stats": {
"failed": 0,
"pending": 0,
"success-with-result": 1,
"success-without-result": 0,
"successful": 1
}
}
}
}

Human Readable Output#

Results#

idresult-urlstats
2651230846634222938https://lgtm.com/query/2651230846634222938successful: 1
success-with-result: 1
success-without-result: 0
failed: 0
pending: 0

lgtm-get-query-job-results-for-project#


Fetch the results of a query job for a specific project

Base Command#

lgtm-get-query-job-results-for-project

Input#

Argument NameDescriptionRequired
queryjob-idThe identifier of the query job, from the task-result given in the response to the initial POST /queryjobs request.Required
project-idThe identifier for the project.Required
startStart point for the page of results.Optional
limitThe maximum number of results to display (less than 100).Optional
nofilterInclude results that are not part of the source tree. These results are filtered out by default.Optional

Context Output#

PathTypeDescription
LGTM.queryjob-project-results.data.lineNumberLGTM Query Job Project Data Line
LGTM.queryjob-project-results.data.fileStringLGTM Query Job Project Data File
LGTM.queryjob-project-results.data.valueStringLGTM Query Job Project Data Value
LGTM.queryjob-project-results.data.urlStringLGTM Query Job Project Data URL
LGTM.queryjob-project-results.nextStringURL for retrieving the next part of the results (if applicable).
LGTM.queryjob_project_results.project.idUnknownProject ID

Command Example#

!lgtm-get-query-job-results-for-project project-id=1511896439667 queryjob-id=2651230846634222938

Context Example#

{
"LGTM": {
"queryjob_project_results": {
"columns": [
"col0",
"src",
"sink",
"col3",
"col4",
"col5"
],
"data": [
[
{
"file": "/src/atom.py",
"line": 45,
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L45",
"value": "BinaryExpr"
},
{
"file": "/src/atom.py",
"line": 42,
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L42",
"value": "externally controlled string"
},
{
"file": "/src/atom.py",
"line": 45,
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L45",
"value": "externally controlled string"
},
{
"value": "This SQL query depends on $@."
},
{
"file": "/src/atom.py",
"line": 42,
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L42",
"value": "username"
},
{
"value": "a user-provided value"
}
]
],
"project": {
"id": 1511896439667,
"name": "my-devsecops/galaxy",
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy",
"url-identifier": "g/my-devsecops/galaxy"
}
}
}
}

Human Readable Output#

Results#

columnsdataproject
col0,
src,
sink,
col3,
col4,
col5
[{'line': 45, 'file': '/src/atom.py', 'value': 'BinaryExpr', 'url': 'https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L45'}, {'line': 42, 'file': '/src/atom.py', 'value': 'externally controlled string', 'url': 'https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L42'}, {'line': 45, 'file': '/src/atom.py', 'value': 'externally controlled string', 'url': 'https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L45'}, {'value': 'This SQL query depends on $@.'}, {'line': 42, 'file': '/src/atom.py', 'value': 'username', 'url': 'https://lgtm.com/projects/g/my-devsecops/galaxy/snapshot/472c1d3933ec0046fd914ef04ff4770454325ccb/files/src/atom.py#L42'}, {'value': 'a user-provided value'}]id: 1511896439667
url-identifier: g/my-devsecops/galaxy
name: my-devsecops/galaxy
url: https://lgtm.com/projects/g/my-devsecops/galaxy

lgtm-get-query-job-results-overview#


Provide a summary of results for the projects in the query job

Base Command#

lgtm-get-query-job-results-overview

Input#

Argument NameDescriptionRequired
queryjob-idThe identifier of the query job, from the task-result given in the response to the initial POST /queryjobs request.Required

Context Output#

PathTypeDescription
LGTM.queryjob-results-overview.data.statusStringDescribes whether the query was sucessfully executed against the project.
LGTM.queryjob-results-overview.data.totalNumberNumber of results returned by the query. This is oken down further into `internal` and `external` results. Only applies if `status` is `success`.
LGTM.queryjob-results-overview.data.internalNumberNumber of results that refer to elements within the source tree. Only applies if `status` is `success`.
LGTM.queryjob-results-overview.data.externalNumberNumber of results that refer to elements outside the source tree (e.g., li aries). Only applies if `status` is `success`.
LGTM.queryjob-results-overview.data.errorStringError message. Only applies if `status` is `error`.
LGTM.queryjob-results-overview.nextStringLGTM Query Job Results Overview Next

Command Example#

!lgtm-get-query-job-results-overview queryjob-id=206061421522356021

Context Example#

{
"LGTM": {
"queryjob_results_overview": {
"data": [
{
"external": 0,
"internal": 0,
"project": {
"id": 1511896439667,
"name": "my-devsecops/galaxy",
"url": "https://lgtm.com/projects/g/my-devsecops/galaxy",
"url-identifier": "g/my-devsecops/galaxy"
},
"status": "success",
"total": 0
}
]
}
}
}

Human Readable Output#

Results#

data
{'project': {'id': 1511896439667, 'url-identifier': 'g/my-devsecops/galaxy', 'name': 'my-devsecops/galaxy', 'url': 'https://lgtm.com/projects/g/my-devsecops/galaxy'}, 'status': 'success', 'total': 0, 'internal': 0, 'external': 0}