Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php taint analysis has duplicate results #122

Closed
prabhu opened this issue Jul 8, 2020 · 4 comments
Closed

php taint analysis has duplicate results #122

prabhu opened this issue Jul 8, 2020 · 4 comments

Comments

@prabhu
Copy link
Contributor

prabhu commented Jul 8, 2020

Sometimes the same result is reported 3 or 4 times. Possibly a downstream defect in the tool but needs investigation.

Example

{
          "message": {
            "markdown": "",
            "text": "Detected tainted shell."
          },
          "level": "error",
          "locations": [
            {
              "physicalLocation": {
                "region": {
                  "snippet": {
                    "text": "\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n"
                  },
                  "startLine": 246
                },
                "artifactLocation": {
                  "uri": "app/ConfigFile.php"
                },
                "contextRegion": {
                  "snippet": {
                    "text": "\t\t}\n\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n\t\t\tthrow new Exceptions\\AppException(\"ERR_CREATE_FILE_FAILURE||{$this->path}\");\n\t\t}\n"
                  },
                  "endLine": 248,
                  "startLine": 245
                }
              }
            }
          ],
          "properties": {
            "issue_confidence": "MEDIUM",
            "issue_severity": "CRITICAL"
          },
          "baselineState": "new",
          "partialFingerprints": {},
          "ruleId": "TaintedInput",
          "ruleIndex": 0
        },
        {
          "message": {
            "markdown": "",
            "text": "Detected tainted shell."
          },
          "level": "error",
          "locations": [
            {
              "physicalLocation": {
                "region": {
                  "snippet": {
                    "text": "\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n"
                  },
                  "startLine": 246
                },
                "artifactLocation": {
                  "uri": "app/ConfigFile.php"
                },
                "contextRegion": {
                  "snippet": {
                    "text": "\t\t}\n\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n\t\t\tthrow new Exceptions\\AppException(\"ERR_CREATE_FILE_FAILURE||{$this->path}\");\n\t\t}\n"
                  },
                  "endLine": 248,
                  "startLine": 245
                }
              }
            }
          ],
          "properties": {
            "issue_confidence": "MEDIUM",
            "issue_severity": "CRITICAL"
          },
          "baselineState": "new",
          "partialFingerprints": {},
          "ruleId": "TaintedInput",
          "ruleIndex": 0
        },
        {
          "message": {
            "markdown": "",
            "text": "Detected tainted shell."
          },
          "level": "error",
          "locations": [
            {
              "physicalLocation": {
                "region": {
                  "snippet": {
                    "text": "\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n"
                  },
                  "startLine": 246
                },
                "artifactLocation": {
                  "uri": "app/ConfigFile.php"
                },
                "contextRegion": {
                  "snippet": {
                    "text": "\t\t}\n\t\tif (false === file_put_contents($this->path, $file, LOCK_EX)) {\n\t\t\tthrow new Exceptions\\AppException(\"ERR_CREATE_FILE_FAILURE||{$this->path}\");\n\t\t}\n"
                  },
                  "endLine": 248,
                  "startLine": 245
                }
              }
            }
          ],
          "properties": {
            "issue_confidence": "MEDIUM",
            "issue_severity": "CRITICAL"
          },
          "baselineState": "new",
          "partialFingerprints": {},
          "ruleId": "TaintedInput",
          "ruleIndex": 0
        },
@prabhu
Copy link
Contributor Author

prabhu commented Jul 8, 2020

Tracked here vimeo/psalm#3773

@muglug
Copy link

muglug commented Jul 8, 2020

I think this tool needs to provide some information about the different paths, otherwise users might think these are duplicate results.

@prabhu
Copy link
Contributor Author

prabhu commented Jul 8, 2020

@muglug
Thanks for the clarification. I will try to understand the new json format and see if the source and sink can be represented better.

@prabhu
Copy link
Contributor Author

prabhu commented Jul 9, 2020

This is implemented by highlighting the source for now. There are still many results being returned and it is not clear whether all of them are valid. Have to filter out false positives at some point.

@prabhu prabhu closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants