Example #1
0
 /// <summary>
 /// Find all respositories with login name of owasp
 /// This routine does not use pagination
 /// </summary>
 public void GitHubListRepositories()
 {
     try {
         GitHubCommits githubCommits = new GitHubCommits();
         Stream        resStream     = null;
         resStream = GitHubRepositories.GitHubURL_ListRepositories().GetResponse().GetResponseStream();
         JArray  jsonVal = JArray.Parse(Request2String.ConvertRequest2String(resStream)) as JArray;
         dynamic repos   = jsonVal;
         foreach (dynamic repo in repos)
         {
             DashBoardData dbData = new DashBoardData();
             if (repo.name == string.Empty)
             {
                 throw new ArgumentNullException();
             }
             dbData.Repo_User             = "******";
             dbData.Repo_Name             = repo.name;
             dbData.Description           = repo.description;
             dbData.OpenIssuesCount       = repo.open_issues_count;
             dbData.Lanuage               = repo.language;
             dbData.Repo_LastActivityDate = repo.updated_at;
             githubCommits.Commits(dbData);
         }
         GitHubFindRespositories();  // find repositories where the user name is not "OWASP"
     }catch (Exception e) {
         System.Console.WriteLine(e.Message);
         Environment.Exit(-1);
     }
 }
Example #2
0
 private void GitHubListCommits(DashBoardData dbData)
 {
     try {
         Stream resStream = null;
         resStream = GitHubCommits.GitHubURL_ListCommits(dbData.Repo_Name).GetResponse().GetResponseStream();
         JArray  jsonVal = JArray.Parse(Request2String.ConvertRequest2String(resStream)) as JArray;
         dynamic commits = jsonVal;
         foreach (dynamic commit in commits)
         {
             dbData.Commit_Author           = commit.commit.committer.name;
             dbData.Commit_LastActivityDate = commit.commit.committer.date;
             try {
                 Program.dictionary.Add(dbData.Repo_Name, dbData);
             } catch (Exception e) {
                 System.Console.WriteLine(e.Message);
                 Environment.Exit(-1);
             }
             break; // First commit in json array will be last commit made for the project
         }
     }
     catch (Exception) {
         dbData.Commit_Author           = string.Empty;
         dbData.Commit_LastActivityDate = DateTime.MinValue;
         try {
             Program.dictionary.Add(dbData.Repo_Name, dbData);
         }catch (ArgumentException) { // we can ignore this
         }
     }
 }
Example #3
0
 /// <summary>
 /// Find OWASP respositories via search, repositories with login name of owasp will not be added.
 /// Pagination is in use
 /// </summary>
 private void GitHubFindRespositories()
 {
     try {
         for (int pageNumber = 1; pageNumber < 32; pageNumber++)
         {
             GitHubCommits githubCommits = new GitHubCommits();
             Stream        resStream     = null;
             resStream = GitHubRepositories.GitHubURL_SearchRepositories(pageNumber).GetResponse().GetResponseStream();
             string  s1      = Request2String.ConvertRequest2String(resStream);
             JObject results = JObject.Parse(s1);
             foreach (var result in results["items"])
             {
                 Console.WriteLine("start specific repo" + "  " + (string)result["name"]);
                 string name  = (string)result["name"];
                 string owner = (string)result["owner"]["login"];
                 if (!owner.ToLower().Equals("owasp"))
                 {
                     resStream = GitHubRepositories.GitHubURL_ARepository(owner, name).GetResponse().GetResponseStream();
                     string        s2     = Request2String.ConvertRequest2String(resStream);
                     JObject       repo   = JObject.Parse(s2);
                     DashBoardData dbData = new DashBoardData();
                     dbData.Repo_User             = (string)repo["owner"]["login"];
                     dbData.Repo_Name             = (string)repo["name"];
                     dbData.Description           = (string)repo["description"];
                     dbData.OpenIssuesCount       = (int)repo["open_issues_count"];
                     dbData.Lanuage               = (string)repo["lanuage"];
                     dbData.Repo_LastActivityDate = (DateTime)repo["updated_at"];
                     System.Console.WriteLine(dbData.Repo_Name);
                     githubCommits.Commits(dbData);
                 }
                 Console.WriteLine("end specific repo");
             }
             Console.WriteLine("End GitHubFindRespositories()");
         }
     }
     catch (Exception e) {
         System.Console.WriteLine(e.Message);
         Environment.Exit(-1);
     }
 }