grafana/plugin-validator

Angular detection: Fetch patterns from GCOM

xnyo opened this issue · 0 comments

xnyo commented

In the legacyplatform inspector (Angular), it would be good to fetch the patterns from GCOM rather than relying on hardcoded ones:

GCOM API: https://grafana.com/api/plugins/angular_patterns

var legacyDetectors = []detector{
&containsBytesDetector{pattern: []byte("PanelCtrl")},
&containsBytesDetector{pattern: []byte("QueryCtrl")},
&containsBytesDetector{pattern: []byte("app/plugins/sdk")},
&containsBytesDetector{pattern: []byte("angular.isNumber(")},
&containsBytesDetector{pattern: []byte("editor.html")},
&containsBytesDetector{pattern: []byte("ctrl.annotation")},
&containsBytesDetector{pattern: []byte("getLegacyAngularInjector")},
&containsBytesDetector{pattern: []byte("System.register(")},
// &regexDetector{regex: regexp.MustCompile(`['"](app/core/.*?)|(app/plugins/.*?)['"]`)},
&regexDetector{regex: regexp.MustCompile(`['"](app/core/utils/promiseToDigest)|(app/plugins/.*?)|(app/core/core_module)['"]`)},
&regexDetector{regex: regexp.MustCompile(`from\s+['"]grafana\/app\/`)},
}

Grafana core already has support for it:

https://github.com/grafana/grafana/blob/e9a12598db238b3923ca30a490d4abcaf0b00b65/pkg/services/pluginsintegration/angulardetectorsprovider/dynamic.go#L110

This would save us from having to open yet another PR when we have to chang the Angular detection patterns