-
Notifications
You must be signed in to change notification settings - Fork 0
/
phylum.go
781 lines (656 loc) · 19.5 KB
/
phylum.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
package phylum
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"golang.org/x/sync/semaphore"
"os"
"reflect"
"strings"
"sync"
"github.com/coreos/go-oidc"
"github.com/go-resty/resty/v2"
"github.com/google/uuid"
"golang.org/x/oauth2"
)
func CheckResponse(resp *resty.Response) *string {
var jsonER JsonErrorResponse
var retString string
if resp.IsError() {
respBody := string(resp.Body())
switch resp.StatusCode() {
case 503:
if strings.Contains(respBody, "upstream connect error or disconnect/reset before headers") {
// Likely Rate Limiting
retString = "503 - Rate Limited"
} else {
retString = respBody
}
default:
err := json.Unmarshal(resp.Body(), &jsonER)
if err != nil {
fmt.Printf("CheckResponse: failed to parse json: %v\n", err)
}
retString = fmt.Sprintf("%v - %v\n", jsonER.Error.Code, jsonER.Error.Description)
}
return &retString
}
return nil
}
type ClientOptions struct {
Token string // Phylum token
ApiHost string // Phylum API Hostname
ApiNoTLS bool // Disable TLS to Phylum API endpoint
}
type PhylumClient struct {
RefreshToken string
OauthToken oauth2.Token
Ctx context.Context
Client *resty.Client
Groups ListUserGroupsResponse
AllProjects []ProjectSummaryResponse
ApiUrl string
}
func NewClient(opts *ClientOptions) (*PhylumClient, error) {
var PhylumToken string = ""
var err error
var apiUrl string
ctx := context.Background()
client := resty.New()
v := reflect.ValueOf(opts)
if v.Kind() == reflect.Ptr && !v.IsNil() {
if opts.Token != "" {
PhylumToken = opts.Token
}
}
// Token wasn't set via options, try to extract from CLI
if PhylumToken == "" {
PhylumToken, err = GetTokenFromCLI()
if err != nil {
return nil, fmt.Errorf("Failed to get token from cli: %v\n", err)
}
}
apiUrl = GetApiUri(opts)
pClient := PhylumClient{
RefreshToken: PhylumToken,
Ctx: ctx,
Client: client,
ApiUrl: apiUrl,
}
if err = pClient.GetAccessToken(); err != nil {
return nil, fmt.Errorf("Failed to get access token: %v\n", err)
}
return &pClient, nil
}
func (p *PhylumClient) GetAccessToken() error {
ctx := context.Background()
provider, err := oidc.NewProvider(ctx, "https://login.phylum.io/realms/phylum")
if err != nil {
fmt.Printf("failed to get oidc provider: %v\n", err)
return err
}
oauth2Config := oauth2.Config{
ClientID: "phylum_cli",
// Discovery returns the OAuth2 endpoints.
Endpoint: provider.Endpoint(),
// "openid" is a required scope for OpenID Connect flows.
Scopes: []string{oidc.ScopeOpenID, "profile", "email"},
}
ts := oauth2Config.TokenSource(ctx, &oauth2.Token{RefreshToken: p.RefreshToken})
tok, err := ts.Token()
if err != nil {
fmt.Printf("failed to get access token: %v\n", err)
return err
}
p.OauthToken = *tok
return nil
}
type AuthStatus struct {
Sub string `json:"sub"`
EmailVerified bool `json:"email_verified"`
Name string `json:"name"`
PreferredUsername string `json:"preferred_username"`
GivenName string `json:"given_name"`
FamilyName string `json:"family_name"`
Email string `json:"email"`
}
func (p *PhylumClient) GetAuthStatus(token string) (bool, error) {
var status AuthStatus
var url string = "https://login.phylum.io/realms/phylum/protocol/openid-connect/userinfo"
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(token).
Get(url)
if resp.StatusCode() != 200 {
return false, nil
}
if err != nil {
fmt.Printf("failed to GetAuthStatus: %v\n", err)
return false, errors.New("failed to GetAuthStatus")
}
body := resp.Body()
err = json.Unmarshal(body, &status)
if err != nil {
fmt.Printf("GetAuthStatus(): failed to parse response: %v\n", err)
return false, err
}
if status.EmailVerified == true {
return true, nil
} else {
return false, nil
}
}
func GetApiUri(opts *ClientOptions) string {
var returnVal string
var scheme string = "https"
var host string
// if p.ApiUri is set, the user is targeting an on-prem environment
if opts.ApiHost != "" {
host = opts.ApiHost
} else {
host = "api.phylum.io"
}
if opts.ApiNoTLS == true {
scheme = "http"
}
returnVal = fmt.Sprintf("%s://%s/api/v0", scheme, host)
return returnVal
}
// GetUserGroups Get Phylum groups for which the user is a member or owner
// Write the result to the PhylumClient struct
func (p *PhylumClient) GetUserGroups() (*ListUserGroupsResponse, error) {
userGroups := new(ListUserGroupsResponse)
//var url string = "https://api.phylum.io/api/v0/groups"
url := fmt.Sprintf("%s/groups", p.ApiUrl)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to get groups: %v\n", err)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, userGroups)
if err != nil {
fmt.Printf("GetGroups(): failed to parse response: %v\n", err)
return nil, err
}
p.Groups = *userGroups
return userGroups, nil
}
func (p *PhylumClient) GetHealth() (bool, error) {
url := fmt.Sprintf("%s/health", p.ApiUrl)
client := resty.New()
token, err := GetTokenFromCLI()
if err != nil {
fmt.Printf("failed to get token from CLI")
return false, err
}
resp, err := client.R().
SetHeader("accept", "application/json").
SetAuthToken(token).
Get(url)
if err != nil {
fmt.Printf("failed to get health")
}
_ = resp
if bytes.Contains(resp.Body(), []byte("alive")) {
return true, nil
}
return false, fmt.Errorf("Health: couldn't find alive")
}
func (p *PhylumClient) ListProjects() ([]ProjectSummaryResponse, error) {
var temp []ProjectSummaryResponse
//var url string = "https://api.phylum.io/api/v0/data/projects/overview"
url := fmt.Sprintf("%s/data/projects/overview", p.ApiUrl)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to get projects: %v\n", err)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, &temp)
if err != nil {
fmt.Printf("GetProjects(): failed to parse response: %v\n", err)
}
return temp, nil
}
// TODO: abstract group elements in the optional struct
type ProjectOpts struct {
GroupName string
}
func (p *PhylumClient) CreateProject(name string, opts *ProjectOpts) (*ProjectSummaryResponse, error) {
var respPSR ProjectSummaryResponse
//var url string = "https://api.phylum.io/api/v0/data/projects"
url := fmt.Sprintf("%s/data/projects", p.ApiUrl)
bodyMap := make(map[string]string, 0)
bodyMap["name"] = name
v := reflect.ValueOf(opts)
if v.Kind() == reflect.Ptr && !v.IsNil() {
if opts.GroupName != "" {
bodyMap["group_name"] = opts.GroupName
}
}
resp, err := p.Client.R().
SetAuthToken(p.OauthToken.AccessToken).
SetBody(bodyMap).
Post(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to create project\n")
return nil, errors.New(*test)
}
err = json.Unmarshal(resp.Body(), &respPSR)
if err != nil {
fmt.Printf("CreateProject(): failed parse json: %v\n", err)
}
return &respPSR, nil
}
func CheckProjectId(projectId string) error {
_, err := uuid.Parse(projectId)
if err != nil {
fmt.Printf("Error: must provide a valid GUID for project ID")
return errors.New("ProjectID is not a guid")
}
return nil
}
func (p *PhylumClient) DeleteProject(projectId string) (*ProjectSummaryResponse, error) {
var respPSR ProjectSummaryResponse
if err := CheckProjectId(projectId); err != nil {
return nil, err
}
url := fmt.Sprintf("%s/data/projects/%v", p.ApiUrl, projectId)
resp, err := p.Client.R().
SetAuthToken(p.OauthToken.AccessToken).
Delete(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to delete project\n")
return nil, errors.New(*test)
}
err = json.Unmarshal(resp.Body(), &respPSR)
if err != nil {
fmt.Printf("DeleteProject(): failed parse json: %v\n", err)
}
return &respPSR, nil
}
// GetProject Gets a project based on a Phylum project ID. It can get user or group projects.
func (p *PhylumClient) GetProject(projectID string) (*ProjectResponse, error) {
var returnProject *ProjectResponse
projects, err := p.ListAllProjects()
if err != nil {
return nil, err
}
// Find the project
var targetProject ProjectSummaryResponse
for _, proj := range projects {
if proj.Id.String() == projectID {
targetProject = proj
}
}
if targetProject.Id.String() == "" {
return nil, fmt.Errorf("GetProject: failed to find project with ID: %v\n", projectID)
}
if *targetProject.GroupName != "" {
// group project
returnProject, err = p.GetGroupProject(*targetProject.GroupName, targetProject.Id.String())
if err != nil {
return nil, err
}
} else {
// user project
returnProject, err = p.GetUserProject(targetProject.Id.String())
if err != nil {
return nil, err
}
}
return returnProject, nil
}
// GetUserProject Gets a user project based on a Phylum project ID.
func (p *PhylumClient) GetUserProject(projectID string) (*ProjectResponse, error) {
var result ProjectResponse
url := fmt.Sprintf("%s/data/projects/%s", p.ApiUrl, projectID)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("GetUserProject(): failed to get projects: %v\n", err)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, &result)
if err != nil {
fmt.Printf("GetUserProject(): failed to parse response: %v\n", err)
}
return &result, nil
}
// TODO: this should be folded into GetProject() with GetProjectOpts struct
func (p *PhylumClient) GetGroupProject(groupName string, projectID string) (*ProjectResponse, error) {
var result ProjectResponse
url := fmt.Sprintf("%s/groups/%s/projects/%s", p.ApiUrl, groupName, projectID)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("GetGroupProject: failed to get project: %s, %s, %s\n", groupName, projectID, *test)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, &result)
if err != nil {
fmt.Printf("GetGroupProject(): failed to parse response: %v\n", err)
}
return &result, nil
}
// TODO: this should be folded into ListProjects() with an optional struct
func (p *PhylumClient) ListGroupProjects(groupName string) ([]ProjectSummaryResponse, error) {
var result []ProjectSummaryResponse
url := fmt.Sprintf("%s/groups/%s/projects", p.ApiUrl, groupName)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to ListGroupProjects: %v\n", err)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, &result)
if err != nil {
fmt.Printf("ListGroupProjects(): failed to parse response: %v\n", err)
}
return result, nil
}
func (p *PhylumClient) ListAllProjects() ([]ProjectSummaryResponse, error) {
var allProjects []ProjectSummaryResponse
// Get all group projects into a slice
groups, err := p.GetUserGroups()
if err != nil {
fmt.Printf("Failed to GetUserGroups(): %v\n", err)
return nil, err
}
for _, group := range groups.Groups {
groupProjectList, err := p.ListGroupProjects(group.GroupName)
if err != nil {
fmt.Printf("Failed to ListGroupProjects: %v\n", err)
return nil, err
}
allProjects = append(allProjects, groupProjectList...)
}
// Add User Projects to slice
projectList, err := p.ListProjects()
if err != nil {
fmt.Printf("Failed to ListProjects(): %v\n", err)
return nil, err
}
allProjects = append(allProjects, projectList...)
return allProjects, nil
}
// Default should get all projects in all groups
func (p *PhylumClient) GetAllProjects() ([]*ProjectResponse, error) {
var result []*ProjectResponse
var allProjectList []ProjectSummaryResponse
// Get all group projects into a slice
groups, err := p.GetUserGroups()
if err != nil {
return nil, err
}
for _, group := range groups.Groups {
groupProjectList, err := p.ListGroupProjects(group.GroupName)
if err != nil {
return nil, err
}
allProjectList = append(allProjectList, groupProjectList...)
}
projectList, err := p.ListProjects()
if err != nil {
return nil, err
}
allProjectList = append(allProjectList, projectList...)
chRecv := make(chan *ProjectResponse)
var wg sync.WaitGroup
for _, proj := range allProjectList {
wg.Add(1)
go func(inProj ProjectSummaryResponse) {
defer wg.Done()
var temp *ProjectResponse
if inProj.GroupName != nil {
temp, err = p.GetGroupProject(*inProj.GroupName, inProj.Id.String())
if err != nil {
fmt.Printf("Failed to GetGroupProject: %v\n", err)
return
}
} else {
temp, err = p.GetUserProject(inProj.Id.String())
if err != nil {
fmt.Printf("Failed to GetUserProject: %v\n", err)
return
}
}
chRecv <- temp
}(proj)
}
go func() {
for res := range chRecv {
result = append(result, res)
}
close(chRecv)
}()
wg.Wait()
return result, err
}
// GetAllGroupProjects Gets all group projects for a given group name
// Commented out for now
func (p *PhylumClient) GetAllGroupProjects(groupName string) ([]*ProjectResponse, []error) {
var result []*ProjectResponse
var errs []error
groupProjectList, err := p.ListGroupProjects(groupName)
if err != nil {
fmt.Printf("Failed to ListGroupProjects: %v\n", err)
errs = append(errs, err)
return nil, errs
}
chRecv := make(chan *ProjectResponse)
chErr := make(chan error)
var wg sync.WaitGroup
sem := semaphore.NewWeighted(5)
ctx := context.TODO()
for _, proj := range groupProjectList {
wg.Add(1)
go func(inProj ProjectSummaryResponse) {
defer wg.Done()
if err = sem.Acquire(ctx, 1); err != nil {
fmt.Printf("Failed to acquire semaphore: %v\n", err)
return
}
defer sem.Release(1)
temp, err := p.GetGroupProject(groupName, inProj.Id.String())
if err != nil {
fmt.Printf("Failed to GetGroupProject: %v\n", err)
chErr <- err
return
}
chRecv <- temp
}(proj)
}
go func() {
for res := range chRecv {
result = append(result, res)
}
close(chRecv)
}()
go func() {
for errPart := range chErr {
errs = append(errs, errPart)
}
close(chErr)
}()
wg.Wait()
return result, errs
}
// TODO: should be removed
func (p *PhylumClient) GetAllGroupProjectsByEcosystem(groupName string, ecosystem string) ([]*ProjectResponse, error) {
var result []*ProjectResponse
var targetList []ProjectSummaryResponse
var wg sync.WaitGroup
groupProjectList, err := p.ListGroupProjects(groupName)
if err != nil {
fmt.Printf("Failed to ListGroupProjects: %v\n", err)
return nil, err
}
for _, proj := range groupProjectList {
if proj.Ecosystem != nil {
projEcosystem := fmt.Sprintf("%v", *proj.Ecosystem)
if projEcosystem == ecosystem {
targetList = append(targetList, proj)
}
}
}
chRecv := make(chan *ProjectResponse)
for _, proj := range targetList {
wg.Add(1)
go func(inProj ProjectSummaryResponse) {
defer wg.Done()
temp, err := p.GetGroupProject(groupName, inProj.Id.String())
if err != nil {
fmt.Printf("Failed to GetGroupProject: %v\n", err)
return
}
chRecv <- temp
}(proj)
}
go func() {
for res := range chRecv {
result = append(result, res)
}
close(chRecv)
}()
wg.Wait()
return result, err
}
func (p *PhylumClient) AnalyzeParsedPackages(projectType string, projectID string, packages *[]PackageDescriptor) (string, error) {
var respSPR SubmitPackageResponse
//var url string = "https://api.phylum.io/api/v0/data/jobs"
url := fmt.Sprintf("%s/data/jobs", p.ApiUrl)
submitPackageRequest := SubmitPackageRequest{
GroupName: nil,
IsUser: true,
Label: "",
Packages: *packages,
Project: projectID,
Type: projectType,
}
resp, err := p.Client.R().
SetAuthToken(p.OauthToken.AccessToken).
SetBody(submitPackageRequest).
Post(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to analyze packages\n")
return "", errors.New(*test)
}
err = json.Unmarshal(resp.Body(), &respSPR)
if err != nil {
fmt.Printf("AnalyzeParsedPackages(): failed parse json: %v\n", err)
return "", fmt.Errorf("AnalyzeParsedPackages(): failed parse json: %v\n", err)
}
if respSPR.JobId.String() == "" {
return "", fmt.Errorf("AnalyzeParsedPackages(): failed to read JobID, submission may not have been successful")
}
return respSPR.JobId.String(), nil
}
// TODO: handle non verbose
// TODO: handle jobstatusresponsevariant
func (p *PhylumClient) GetJobVerbose(jobID string) (*JobStatusResponseForPackageStatusExtended, *[]byte, error) {
var jobResponse JobStatusResponseForPackageStatusExtended
url := fmt.Sprintf("%s/data/jobs/%s?verbose=true", p.ApiUrl, jobID)
resp, err := p.Client.R().
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to GetJob\n")
return nil, nil, errors.New(*test)
}
err = json.Unmarshal(resp.Body(), &jobResponse)
if err != nil {
fmt.Printf("GetJob(): failed parse json: %v\n", err)
return nil, nil, err
}
jsonData := resp.Body()
return &jobResponse, &jsonData, nil
}
// ParseLockfile parses a lockfile into a struct that can be submitted for analysis.
// It takes the path to a lockfile as input, and returns a pointer to a slice of PackageDescriptors
// This method uses an online service from Phylum to parse packages and requires access to the Internet
func (p *PhylumClient) ParseLockfile(lockfilePath string) (*[]PackageDescriptor, error) {
if _, err := os.Stat(lockfilePath); errors.Is(err, os.ErrNotExist) {
return nil, fmt.Errorf("lockfilePath: %v is not a file", lockfilePath)
}
var packages []PackageDescriptor
url := "https://parse.phylum.io"
resp, err := p.Client.R().
SetAuthToken(p.OauthToken.AccessToken).
SetFile("lockfile", lockfilePath).
Post(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("ParseLockfile(): failed to ParseLockfile\n")
return nil, errors.New(*test)
}
err = json.Unmarshal(resp.Body(), &packages)
if err != nil {
fmt.Printf("ParseLockfile(): failed parse json: %v\n", err)
return nil, err
}
return &packages, nil
}
func (p *PhylumClient) GetProjectPreferences(projectID string) (*ProjectPreferencesResponse, error) {
var result ProjectPreferencesResponse
url := fmt.Sprintf("%s/preferences/project/%s", p.ApiUrl, projectID)
resp, err := p.Client.R().
SetHeader("accept", "application/json").
SetAuthToken(p.OauthToken.AccessToken).
Get(url)
test := CheckResponse(resp)
if test != nil || err != nil {
fmt.Printf("failed to get projects: %v\n", err)
return nil, errors.New(*test)
}
body := resp.Body()
err = json.Unmarshal(body, &result)
if err != nil {
fmt.Printf("GetProjects(): failed to parse response: %v\n", err)
}
return &result, nil
}
// GetProjectIssues gets the issues for a project. Only returns issues that are not ignored/suppressed
func (p *PhylumClient) GetProjectIssues(projectId string) ([]IssuesListItem, error) {
var issues []IssuesListItem
if err := CheckProjectId(projectId); err != nil {
return nil, err
}
projectResponse, err := p.GetUserProject(projectId)
if err != nil {
return nil, err
}
for _, elem := range projectResponse.Issues {
if elem.Ignored == "false" {
issues = append(issues, elem)
}
}
return issues, nil
}