f3rb 6.4.2 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of f3rb might be problematic. Click here for more details.

package/mvn.go DELETED
@@ -1,120 +0,0 @@
1
- package main
2
-
3
- import (
4
- "encoding/json"
5
- "encoding/xml"
6
- "fmt"
7
- "io/ioutil"
8
- "log"
9
- "net/http"
10
- "strings"
11
- "time"
12
- )
13
-
14
- // NPMLookup represents a collection of npm packages to be tested for dependency confusion.
15
- type MVNLookup struct {
16
- Packages []MVNPackage
17
- Verbose bool
18
- }
19
-
20
- type MVNPackage struct {
21
- Group string
22
- Artifact string
23
- Version string
24
- }
25
-
26
- // NewNPMLookup constructs an `MVNLookup` struct and returns it.
27
- func NewMVNLookup(verbose bool) PackageResolver {
28
- return &MVNLookup{Packages: []MVNPackage{}, Verbose: verbose}
29
- }
30
-
31
- // ReadPackagesFromFile reads package information from an npm package.json file
32
- //
33
- // Returns any errors encountered
34
- func (n *MVNLookup) ReadPackagesFromFile(filename string) error {
35
- rawfile, err := ioutil.ReadFile(filename)
36
- if err != nil {
37
- return err
38
- }
39
-
40
- fmt.Print("Checking: filename: " + filename + "\n")
41
-
42
- var project MavenProject
43
- if err := xml.Unmarshal([]byte(rawfile), &project); err != nil {
44
- log.Fatalf("unable to unmarshal pom file. Reason: %s\n", err)
45
- }
46
-
47
- for _, dep := range project.Dependencies {
48
- n.Packages = append(n.Packages, MVNPackage{dep.GroupId, dep.ArtifactId, dep.Version})
49
- }
50
-
51
- for _, dep := range project.Build.Plugins {
52
- n.Packages = append(n.Packages, MVNPackage{dep.GroupId, dep.ArtifactId, dep.Version})
53
- }
54
-
55
- for _, build := range project.Profiles {
56
- for _, dep := range build.Build.Plugins {
57
- n.Packages = append(n.Packages, MVNPackage{dep.GroupId, dep.ArtifactId, dep.Version})
58
- }
59
- }
60
-
61
- return nil
62
- }
63
-
64
- // PackagesNotInPublic determines if an npm package does not exist in the public npm package repository.
65
- //
66
- // Returns a slice of strings with any npm packages not in the public npm package repository
67
- func (n *MVNLookup) PackagesNotInPublic() []string {
68
- notavail := []string{}
69
- for _, pkg := range n.Packages {
70
- if !n.isAvailableInPublic(pkg, 0) {
71
- notavail = append(notavail, pkg.Group+"/"+pkg.Artifact)
72
- }
73
- }
74
- return notavail
75
- }
76
-
77
- // isAvailableInPublic determines if an npm package exists in the public npm package repository.
78
- //
79
- // Returns true if the package exists in the public npm package repository.
80
- func (n *MVNLookup) isAvailableInPublic(pkg MVNPackage, retry int) bool {
81
- if retry > 3 {
82
- fmt.Printf(" [W] Maximum number of retries exhausted for package: %s\n", pkg.Group)
83
- return false
84
- }
85
- if pkg.Group == "" {
86
- return true
87
- }
88
-
89
- group := strings.Replace(pkg.Group, ".", "/", -1)
90
- if n.Verbose {
91
- fmt.Print("Checking: https://repo1.maven.org/maven2/" + group + "/ ")
92
- }
93
- resp, err := http.Get("https://repo1.maven.org/maven2/" + group + "/")
94
- if err != nil {
95
- fmt.Printf(" [W] Error when trying to request https://repo1.maven.org/maven2/"+group+"/ : %s\n", err)
96
- return false
97
- }
98
- defer resp.Body.Close()
99
- if n.Verbose {
100
- fmt.Printf("%s\n", resp.Status)
101
- }
102
- if resp.StatusCode == http.StatusOK {
103
- npmResp := NpmResponse{}
104
- body, _ := ioutil.ReadAll(resp.Body)
105
- _ = json.Unmarshal(body, &npmResp)
106
- if npmResp.NotAvailable() {
107
- if n.Verbose {
108
- fmt.Printf("[W] Package %s was found, but all its versions are unpublished, making anyone able to takeover the namespace.\n", pkg.Group)
109
- }
110
- return false
111
- }
112
- return true
113
- } else if resp.StatusCode == 429 {
114
- fmt.Printf(" [!] Server responded with 429 (Too many requests), throttling and retrying...\n")
115
- time.Sleep(10 * time.Second)
116
- retry = retry + 1
117
- return n.isAvailableInPublic(pkg, retry)
118
- }
119
- return false
120
- }
package/mvnparser.go DELETED
@@ -1,139 +0,0 @@
1
- //
2
- // https://raw.githubusercontent.com/creekorful/mvnparser/master/parser.go
3
- //
4
- // MIT License
5
- //
6
- // Copyright (c) 2019 Aloïs Micard
7
- //
8
- // Permission is hereby granted, free of charge, to any person obtaining a copy
9
- // of this software and associated documentation files (the "Software"), to deal
10
- // in the Software without restriction, including without limitation the rights
11
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- // copies of the Software, and to permit persons to whom the Software is
13
- // furnished to do so, subject to the following conditions:
14
- //
15
- // The above copyright notice and this permission notice shall be included in all
16
- // copies or substantial portions of the Software.
17
- //
18
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
- // SOFTWARE.
25
-
26
- package main
27
-
28
- import (
29
- "encoding/xml"
30
- "io"
31
- )
32
-
33
- // Represent a POM file
34
- type MavenProject struct {
35
- XMLName xml.Name `xml:"project"`
36
- ModelVersion string `xml:"modelVersion"`
37
- Parent Parent `xml:"parent"`
38
- GroupId string `xml:"groupId"`
39
- ArtifactId string `xml:"artifactId"`
40
- Version string `xml:"version"`
41
- Packaging string `xml:"packaging"`
42
- Name string `xml:"name"`
43
- Repositories []Repository `xml:"repositories>repository"`
44
- Properties Properties `xml:"properties"`
45
- DependencyManagement DependencyManagement `xml:"dependencyManagement"`
46
- Dependencies []Dependency `xml:"dependencies>dependency"`
47
- Profiles []Profile `xml:"profiles"`
48
- Build Build `xml:"build"`
49
- PluginRepositories []PluginRepository `xml:"pluginRepositories>pluginRepository"`
50
- Modules []string `xml:"modules>module"`
51
- }
52
-
53
- // Represent the parent of the project
54
- type Parent struct {
55
- GroupId string `xml:"groupId"`
56
- ArtifactId string `xml:"artifactId"`
57
- Version string `xml:"version"`
58
- }
59
-
60
- // Represent a dependency of the project
61
- type Dependency struct {
62
- XMLName xml.Name `xml:"dependency"`
63
- GroupId string `xml:"groupId"`
64
- ArtifactId string `xml:"artifactId"`
65
- Version string `xml:"version"`
66
- Classifier string `xml:"classifier"`
67
- Type string `xml:"type"`
68
- Scope string `xml:"scope"`
69
- Exclusions []Exclusion `xml:"exclusions>exclusion"`
70
- }
71
-
72
- // Represent an exclusion
73
- type Exclusion struct {
74
- XMLName xml.Name `xml:"exclusion"`
75
- GroupId string `xml:"groupId"`
76
- ArtifactId string `xml:"artifactId"`
77
- }
78
-
79
- type DependencyManagement struct {
80
- Dependencies []Dependency `xml:"dependencies>dependency"`
81
- }
82
-
83
- // Represent a repository
84
- type Repository struct {
85
- Id string `xml:"id"`
86
- Name string `xml:"name"`
87
- Url string `xml:"url"`
88
- }
89
-
90
- type Profile struct {
91
- Id string `xml:"id"`
92
- Build Build `xml:"build"`
93
- }
94
-
95
- type Build struct {
96
- // todo: final name ?
97
- Plugins []Plugin `xml:"plugins>plugin"`
98
- }
99
-
100
- type Plugin struct {
101
- XMLName xml.Name `xml:"plugin"`
102
- GroupId string `xml:"groupId"`
103
- ArtifactId string `xml:"artifactId"`
104
- Version string `xml:"version"`
105
- //todo something like: Configuration map[string]string `xml:"configuration"`
106
- // todo executions
107
- }
108
-
109
- // Represent a pluginRepository
110
- type PluginRepository struct {
111
- Id string `xml:"id"`
112
- Name string `xml:"name"`
113
- Url string `xml:"url"`
114
- }
115
-
116
- // Represent Properties
117
- type Properties map[string]string
118
-
119
- func (p *Properties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
120
- *p = map[string]string{}
121
- for {
122
- key := ""
123
- value := ""
124
- token, err := d.Token()
125
- if err == io.EOF {
126
- break
127
- }
128
- switch tokenType := token.(type) {
129
- case xml.StartElement:
130
- key = tokenType.Name.Local
131
- err := d.DecodeElement(&value, &start)
132
- if err != nil {
133
- return err
134
- }
135
- (*p)[key] = value
136
- }
137
- }
138
- return nil
139
- }
package/npm.go DELETED
@@ -1,210 +0,0 @@
1
- package main
2
-
3
- import (
4
- "encoding/json"
5
- "fmt"
6
- "io/ioutil"
7
- "net/http"
8
- "strings"
9
- "time"
10
- )
11
-
12
- // PackageJSON represents the dependencies of an npm package
13
- type PackageJSON struct {
14
- Dependencies map[string]string `json:"dependencies,omitempty"`
15
- DevDependencies map[string]string `json:"devDependencies,omitempty"`
16
- PeerDependencies map[string]string `json:"peerDependencies,omitempty"`
17
- BundledDependencies []string `json:"bundledDependencies,omitempty"`
18
- BundleDependencies []string `json:"bundleDependencies,omitempty"`
19
- OptionalDependencies map[string]string `json:"optionalDependencies,omitempty"`
20
- }
21
-
22
- type NpmResponse struct {
23
- ID string `json:"_id"`
24
- Name string `json:"name"`
25
- Time struct {
26
- Unpublished NpmResponseUnpublished `json:"unpublished"`
27
- } `json:"time"`
28
- }
29
-
30
- type NpmResponseUnpublished struct {
31
- Maintainers []struct {
32
- Email string `json:"email"`
33
- Name string `json:"name"`
34
- } `json:"maintainers"`
35
- Name string `json:"name"`
36
- Tags struct {
37
- Latest string `json:"latest"`
38
- } `json:"tags"`
39
- Time time.Time `json:"time"`
40
- Versions []string `json:"versions"`
41
- }
42
-
43
- // NotAvailable returns true if the package has its all versions unpublished making it susceptible for takeover
44
- func (n *NpmResponse) NotAvailable() bool {
45
- // Check if a known field has a value
46
- return len(n.Time.Unpublished.Name) > 0
47
- }
48
-
49
- // NPMLookup represents a collection of npm packages to be tested for dependency confusion.
50
- type NPMLookup struct {
51
- Packages []NPMPackage
52
- Verbose bool
53
- }
54
-
55
- type NPMPackage struct {
56
- Name string
57
- Version string
58
- }
59
-
60
- // NewNPMLookup constructs an `NPMLookup` struct and returns it.
61
- func NewNPMLookup(verbose bool) PackageResolver {
62
- return &NPMLookup{Packages: []NPMPackage{}, Verbose: verbose}
63
- }
64
-
65
- // ReadPackagesFromFile reads package information from an npm package.json file
66
- //
67
- // Returns any errors encountered
68
- func (n *NPMLookup) ReadPackagesFromFile(filename string) error {
69
- rawfile, err := ioutil.ReadFile(filename)
70
- if err != nil {
71
- return err
72
- }
73
- data := PackageJSON{}
74
- err = json.Unmarshal([]byte(rawfile), &data)
75
- if err != nil {
76
- fmt.Printf(" [W] Non-fatal issue encountered while reading %s : %s\n", filename, err)
77
- }
78
- for pkgname, pkgversion := range data.Dependencies {
79
- n.Packages = append(n.Packages, NPMPackage{pkgname, pkgversion})
80
- }
81
- for pkgname, pkgversion := range data.DevDependencies {
82
- n.Packages = append(n.Packages, NPMPackage{pkgname, pkgversion})
83
- }
84
- for pkgname, pkgversion := range data.PeerDependencies {
85
- n.Packages = append(n.Packages, NPMPackage{pkgname, pkgversion})
86
- }
87
- for pkgname, pkgversion := range data.OptionalDependencies {
88
- n.Packages = append(n.Packages, NPMPackage{pkgname, pkgversion})
89
- }
90
- for _, pkgname := range data.BundledDependencies {
91
- n.Packages = append(n.Packages, NPMPackage{pkgname, ""})
92
- }
93
- for _, pkgname := range data.BundleDependencies {
94
- n.Packages = append(n.Packages, NPMPackage{pkgname, ""})
95
- }
96
- return nil
97
- }
98
-
99
- // PackagesNotInPublic determines if an npm package does not exist in the public npm package repository.
100
- //
101
- // Returns a slice of strings with any npm packages not in the public npm package repository
102
- func (n *NPMLookup) PackagesNotInPublic() []string {
103
- notavail := []string{}
104
- for _, pkg := range n.Packages {
105
- if n.localReference(pkg.Version) || n.urlReference(pkg.Version) || n.gitReference(pkg.Version) {
106
- continue
107
- }
108
- if n.gitHubReference(pkg.Version) {
109
- if !n.gitHubOrgExists(pkg.Version) {
110
- notavail = append(notavail, pkg.Name)
111
- continue
112
- } else {
113
- continue
114
- }
115
- }
116
- if !n.isAvailableInPublic(pkg.Name, 0) {
117
- notavail = append(notavail, pkg.Name)
118
- }
119
- }
120
- return notavail
121
- }
122
-
123
- // isAvailableInPublic determines if an npm package exists in the public npm package repository.
124
- //
125
- // Returns true if the package exists in the public npm package repository.
126
- func (n *NPMLookup) isAvailableInPublic(pkgname string, retry int) bool {
127
- if retry > 3 {
128
- fmt.Printf(" [W] Maximum number of retries exhausted for package: %s\n", pkgname)
129
- return false
130
- }
131
- if n.Verbose {
132
- fmt.Print("Checking: https://registry.npmjs.org/" + pkgname + "/ : ")
133
- }
134
- resp, err := http.Get("https://registry.npmjs.org/" + pkgname + "/")
135
- if err != nil {
136
- fmt.Printf(" [W] Error when trying to request https://registry.npmjs.org/"+pkgname+"/ : %s\n", err)
137
- return false
138
- }
139
- defer resp.Body.Close()
140
- if n.Verbose {
141
- fmt.Printf("%s\n", resp.Status)
142
- }
143
- if resp.StatusCode == http.StatusOK {
144
- npmResp := NpmResponse{}
145
- body, _ := ioutil.ReadAll(resp.Body)
146
- _ = json.Unmarshal(body, &npmResp)
147
- if npmResp.NotAvailable() {
148
- if n.Verbose {
149
- fmt.Printf("[W] Package %s was found, but all its versions are unpublished, making anyone able to takeover the namespace.\n", pkgname)
150
- }
151
- return false
152
- }
153
- return true
154
- } else if resp.StatusCode == 429 {
155
- fmt.Printf(" [!] Server responded with 429 (Too many requests), throttling and retrying...\n")
156
- time.Sleep(10 * time.Second)
157
- retry = retry + 1
158
- return n.isAvailableInPublic(pkgname, retry)
159
- }
160
- return false
161
- }
162
-
163
- // localReference checks if the package version is in fact a reference to filesystem
164
- func (n *NPMLookup) localReference(pkgversion string) bool {
165
- return strings.HasPrefix(strings.ToLower(pkgversion), "file:")
166
- }
167
-
168
- // urlReference checks if the package version is in fact a reference to a direct URL
169
- func (n *NPMLookup) urlReference(pkgversion string) bool {
170
- pkgversion = strings.ToLower(pkgversion)
171
- return strings.HasPrefix(pkgversion, "http:") || strings.HasPrefix(pkgversion, "https:")
172
- }
173
-
174
- // gitReference checks if the package version is in fact a reference to a remote git repository
175
- func (n *NPMLookup) gitReference(pkgversion string) bool {
176
- pkgversion = strings.ToLower(pkgversion)
177
- gitResources := []string{"git+ssh:", "git+http:", "git+https:", "git:"}
178
- for _, r := range gitResources {
179
- if strings.HasPrefix(pkgversion, r) {
180
- return true
181
- }
182
- }
183
- return false
184
- }
185
-
186
- // gitHubReference checks if the package version refers to a GitHub repository
187
- func (n *NPMLookup) gitHubReference(pkgversion string) bool {
188
- return !strings.HasPrefix(pkgversion, "@") && strings.Contains(pkgversion, "/")
189
- }
190
-
191
- // gitHubOrgExists returns true if GitHub organization / user exists
192
- func (n NPMLookup) gitHubOrgExists(pkgversion string) bool {
193
- orgName := strings.Split(pkgversion, "/")[0]
194
- if len(orgName) > 0 {
195
- if n.Verbose {
196
- fmt.Print("Checking: https://github.com/" + orgName + " : ")
197
- }
198
- resp, err := http.Get("https://github.com/" + orgName)
199
- if err != nil {
200
- fmt.Printf(" [W] Error while trying to request https://github.com/"+orgName+" : %s\n", err)
201
- return false
202
- }
203
- defer resp.Body.Close()
204
- if n.Verbose {
205
- fmt.Printf("%d\n", resp.StatusCode)
206
- }
207
- return resp.StatusCode == 200
208
- }
209
- return false
210
- }
package/pip.go DELETED
@@ -1,99 +0,0 @@
1
- package main
2
-
3
- import (
4
- "fmt"
5
- "io/ioutil"
6
- "net/http"
7
- "strings"
8
- )
9
-
10
- // PythonLookup represents a collection of python packages to be tested for dependency confusion.
11
- type PythonLookup struct {
12
- Packages []string
13
- Verbose bool
14
- }
15
-
16
- // NewPythonLookup constructs a `PythonLookup` struct and returns it
17
- func NewPythonLookup(verbose bool) PackageResolver {
18
- return &PythonLookup{Packages: []string{}, Verbose: verbose}
19
- }
20
-
21
- // ReadPackagesFromFile reads package information from a python `requirements.txt` file
22
- //
23
- // Returns any errors encountered
24
- func (p *PythonLookup) ReadPackagesFromFile(filename string) error {
25
- rawfile, err := ioutil.ReadFile(filename)
26
- if err != nil {
27
- return err
28
- }
29
- line := ""
30
- for _, l := range strings.Split(string(rawfile), "\n") {
31
- l = strings.TrimSpace(l)
32
- if strings.HasPrefix(l, "#") {
33
- continue
34
- }
35
- if len(l) > 0 {
36
- // Support line continuation
37
- if strings.HasSuffix(l, "\\") {
38
- line += l[:len(l) - 1]
39
- continue
40
- }
41
- line += l
42
- pkgrow := strings.FieldsFunc(line, p.pipSplit)
43
- if len(pkgrow) > 0 {
44
- p.Packages = append(p.Packages, strings.TrimSpace(pkgrow[0]))
45
- }
46
- // reset the line variable
47
- line = ""
48
- }
49
- }
50
- return nil
51
- }
52
-
53
- // PackagesNotInPublic determines if a python package does not exist in the pypi package repository.
54
- //
55
- // Returns a slice of strings with any python packages not in the pypi package repository
56
- func (p *PythonLookup) PackagesNotInPublic() []string {
57
- notavail := []string{}
58
- for _, pkg := range p.Packages {
59
- if !p.isAvailableInPublic(pkg) {
60
- notavail = append(notavail, pkg)
61
- }
62
- }
63
- return notavail
64
- }
65
-
66
- func (p *PythonLookup) pipSplit(r rune) bool {
67
- delims := []rune{
68
- '=',
69
- '<',
70
- '>',
71
- '!',
72
- ' ',
73
- '~',
74
- '#',
75
- '[',
76
- }
77
- return inSlice(r, delims)
78
- }
79
-
80
- // isAvailableInPublic determines if a python package exists in the pypi package repository.
81
- //
82
- // Returns true if the package exists in the pypi package repository.
83
- func (p *PythonLookup) isAvailableInPublic(pkgname string) bool {
84
- if p.Verbose {
85
- fmt.Print("Checking: https://pypi.org/project/" + pkgname + "/ : ")
86
- }
87
- resp, err := http.Get("https://pypi.org/project/" + pkgname + "/")
88
- if err != nil {
89
- fmt.Printf(" [W] Error when trying to request https://pypi.org/project/"+pkgname+"/ : %s\n", err)
90
- return false
91
- }
92
- if p.Verbose {
93
- fmt.Printf("%s\n", resp.Status)
94
- }
95
- if resp.StatusCode == http.StatusOK {
96
- return true
97
- }
98
- return false
99
- }
package/r.txt DELETED
@@ -1,7 +0,0 @@
1
- jinja2<3.1.0
2
- Flask==1.1.2
3
- itsdangerous==2.0.1
4
- # Flask_Caching==1.9.0
5
- Werkzeug==1.0.1
6
- flask_debugtoolbar==0.11.0
7
- # flask_mail==0.9.1