コード例 #1
0
        private async void ShareButtonClick(object sender, RoutedEventArgs e)
        {
            (Repository repository, Commit commit) = shareVulnerabilityFromHistoryCommand.GetSelectedCommit();
            using (HttpClient httpClient = new HttpClient())
            {
                using (MultipartFormDataContent formData = new MultipartFormDataContent())
                {
                    CweEntry selectedEntry = cweComboBox.SelectedItem as CweEntry;
                    formData.Add(new StringContent(selectedEntry.Id.ToString()), "CweId");
                    formData.Add(new StringContent(commit.Message), "CommitMessage");
                    formData.Add(new StringContent(commentTextBox.Text), "Comment");
                    int fileCount = 0;
                    foreach (TreeEntry treeEntry in commit.Tree)
                    {
                        fileCount++;
                        if (treeEntry.TargetType == TreeEntryTargetType.Blob)
                        {
                            Blob blob = treeEntry.Target as Blob;
                            formData.Add(new StreamContent(blob.GetContentStream()), $"currentFile{fileCount}", treeEntry.Path);
                            TreeEntry previousVersion = GetPreviousVersionOfFile(repository, treeEntry, commit);
                            if (previousVersion != null)
                            {
                                formData.Add(new StreamContent(blob.GetContentStream()), $"previousFile{fileCount}", treeEntry.Path);
                            }
                        }
                    }

                    string apiUrl = "http://micscan.local/api/Share";
                    HttpResponseMessage response = await httpClient.PostAsync(apiUrl, formData);
                }
            }
        }
コード例 #2
0
        private async void ShareButtonClick(object sender, RoutedEventArgs e)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            shareButton.IsEnabled       = false;
            shareProgressBar.Visibility = Visibility.Visible;
            shareProgressBar.Minimum    = 0;
            shareProgressBar.Maximum    = 1.0;
            await shareVulnerabilityFromHistoryCommand.ShowOutputWindow();

            await shareVulnerabilityFromHistoryCommand.WriteToOutput("Beginning to share vulnerable commit.");

            (Repository repository, Commit commit) = await shareVulnerabilityFromHistoryCommand.GetSelectedCommit();
            await ShareCommit(repository, commit);

            await shareVulnerabilityFromHistoryCommand.WriteToOutput("Upload complete. Thank you for sharing this vulnerability!");

            Close();
        }