mirror of
https://github.com/github/codeql.git
synced 2026-05-01 03:35:13 +02:00
Merge pull request #712 from markshannon/python-fix-odasa-7307
Python: Detect a wider range of generated files.
This commit is contained in:
@@ -24,6 +24,8 @@ library class GenericGeneratedFile extends GeneratedFile {
|
||||
(lax_generated_by(this, _) or lax_generated_from(this, _)) and dont_modify(this)
|
||||
or
|
||||
strict_generated_by(this, _) or strict_generated_from(this, _)
|
||||
or
|
||||
auto_generated(this)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -78,8 +80,15 @@ private predicate dont_modify(File f) {
|
||||
comment_or_docstring(f, _).regexpMatch("(?is).*\\b(Do not|Don't) (edit|modify|make changes)\\b.*")
|
||||
}
|
||||
|
||||
private predicate auto_generated(File f) {
|
||||
exists(Comment c |
|
||||
c.getLocation().getFile() = f and
|
||||
c.getText().regexpMatch("(?is)# *this +(code|file) +is +(auto(matically)?[ -]?generated|created automatically).*")
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* A file generated by a template engine
|
||||
*/
|
||||
abstract library class SpecificGeneratedFile extends GeneratedFile {
|
||||
|
||||
Reference in New Issue
Block a user