Skip to content
This repository
Browse code

Option to setting a ssh connection port on GUI client

  • Loading branch information...
commit 3dfc2d9951f743aa0310aee4f0f5b941d7273f97 1 parent a1d9132
cpaiva authored
2  Modulo.Collect.Console/Options.cs
@@ -167,7 +167,7 @@ public string GetUsage()
167 167 help.AdditionalNewLineAfterOption = true;
168 168 help.Copyright = new CopyrightInfo("Modulo Security Solutions", 2011, 2011);
169 169 help.AddPreOptionsLine("This is free software. You may redistribute copies of it under the terms of");
170   - help.AddPreOptionsLine("the License <http://modsic.codeplex.com/license>.");
  170 + help.AddPreOptionsLine("the License <https://github.com/modulogrc/modSIC/blob/master/README>.");
171 171 help.AddPreOptionsLine("");
172 172 help.AddPreOptionsLine(String.Format("Usage: {0} -c -m <server> -u <username> -p <password> -t <target> -y <target-username> -z <target-password>", programName));
173 173 help.AddPreOptionsLine("");
18 Modulo.Collect.GraphicalConsole.Tests/ExternalVariableControllerTest.cs
@@ -47,23 +47,23 @@ public void Should_be_possible_create_controls_from_external_variables()
47 47 Assert.AreEqual(16, fakeController.Controls.Count);
48 48
49 49 var controls = fakeController.Controls.ToArray();
50   - Assert.AreEqual("Variable 1 (String)", controls[0].Text);
  50 + Assert.AreEqual("Variable 1 (string)", controls[0].Text);
51 51 Assert.AreEqual("oval:tutorial:var:1", controls[1].Name);
52 52 Assert.IsTrue(controls[1] is TextBox);
53 53
54   - Assert.AreEqual("Variable 2 (String)", controls[2].Text);
  54 + Assert.AreEqual("Variable 2 (string)", controls[2].Text);
55 55 Assert.AreEqual("oval:tutorial:var:2", controls[3].Name);
56 56 Assert.IsTrue(controls[3] is TextBox);
57 57
58   - Assert.AreEqual("Variable 3 (Int)", controls[4].Text);
  58 + Assert.AreEqual("Variable 3 (int)", controls[4].Text);
59 59 Assert.AreEqual("oval:tutorial:var:3", controls[5].Name);
60 60 Assert.IsTrue(controls[5] is NumericUpDown);
61 61
62   - Assert.AreEqual("Variable 4 (Int)", controls[6].Text);
  62 + Assert.AreEqual("Variable 4 (int)", controls[6].Text);
63 63 Assert.AreEqual("oval:tutorial:var:4", controls[7].Name);
64 64 Assert.IsTrue(controls[7] is NumericUpDown);
65 65
66   - Assert.AreEqual("Variable 5 (String)", controls[8].Text);
  66 + Assert.AreEqual("Variable 5 (string)", controls[8].Text);
67 67 Assert.AreEqual("oval:tutorial:var:5", controls[9].Name);
68 68 Assert.IsTrue(controls[9] is ComboBox);
69 69 var combo = controls[9] as ComboBox;
@@ -76,25 +76,25 @@ public void Should_be_possible_create_controls_from_external_variables()
76 76 Assert.AreEqual("Value 4", ((ComboBoxItem)combo.Items[3]).Display);
77 77 Assert.AreEqual("AUDIT_SUCCESS_FAILURE", ((ComboBoxItem) combo.Items[3]).Value);
78 78
79   - Assert.AreEqual("Variable 6 (Boolean)", controls[10].Text);
  79 + Assert.AreEqual("Variable 6 (boolean)", controls[10].Text);
80 80 Assert.AreEqual("oval:tutorial:var:6", controls[10].Name);
81 81 Assert.IsTrue(controls[10] is CheckBox);
82 82
83   - Assert.AreEqual("Variable 7 (Binary)", controls[11].Text);
  83 + Assert.AreEqual("Variable 7 (binary)", controls[11].Text);
84 84 Assert.AreEqual("oval:tutorial:var:7", controls[12].Name);
85 85 Assert.IsTrue(controls[12] is TextBox);
86 86
87 87 Assert.AreEqual("oval:tutorial:var:8", controls[13].Name);
88 88 Assert.IsTrue(controls[13] is Panel);
89 89 var panelControls = controls[13].Controls;
90   - Assert.AreEqual("Variable 8 (Boolean)", panelControls[0].Text);
  90 + Assert.AreEqual("Variable 8 (boolean)", panelControls[0].Text);
91 91 Assert.IsTrue(panelControls[0] is Label);
92 92 Assert.AreEqual("True", panelControls[1].Text);
93 93 Assert.IsTrue(panelControls[0] is Label);
94 94 Assert.AreEqual("False", panelControls[2].Text);
95 95 Assert.IsTrue(panelControls[0] is Label);
96 96
97   - Assert.AreEqual("Variable 9 (Int)", controls[14].Text);
  97 + Assert.AreEqual("Variable 9 (int)", controls[14].Text);
98 98 Assert.AreEqual("oval:tutorial:var:9", controls[15].Name);
99 99 Assert.IsTrue(controls[15] is ComboBox);
100 100 combo = controls[15] as ComboBox;
7 Modulo.Collect.GraphicalConsole/AboutBox.Designer.cs
@@ -129,10 +129,10 @@ private void InitializeComponent()
129 129 this.lnkWebsite.AutoSize = true;
130 130 this.lnkWebsite.Location = new System.Drawing.Point(169, 62);
131 131 this.lnkWebsite.Name = "lnkWebsite";
132   - this.lnkWebsite.Size = new System.Drawing.Size(126, 13);
  132 + this.lnkWebsite.Size = new System.Drawing.Size(94, 13);
133 133 this.lnkWebsite.TabIndex = 25;
134 134 this.lnkWebsite.TabStop = true;
135   - this.lnkWebsite.Text = "Visit modSIC at CodePlex";
  135 + this.lnkWebsite.Text = "Visit modSIC at Git";
136 136 this.lnkWebsite.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkWebsite_LinkClicked);
137 137 //
138 138 // lnkLicense
@@ -141,7 +141,7 @@ private void InitializeComponent()
141 141 this.lnkLicense.AutoSize = true;
142 142 this.lnkLicense.Location = new System.Drawing.Point(169, 97);
143 143 this.lnkLicense.Name = "lnkLicense";
144   - this.lnkLicense.Size = new System.Drawing.Size(165, 13);
  144 + this.lnkLicense.Size = new System.Drawing.Size(164, 13);
145 145 this.lnkLicense.TabIndex = 26;
146 146 this.lnkLicense.TabStop = true;
147 147 this.lnkLicense.Text = "View modSIC License Agreement";
@@ -152,6 +152,7 @@ private void InitializeComponent()
152 152 this.AcceptButton = this.okButton;
153 153 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
154 154 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
  155 + this.BackColor = System.Drawing.SystemColors.Window;
155 156 this.ClientSize = new System.Drawing.Size(435, 174);
156 157 this.Controls.Add(this.tableLayoutPanel);
157 158 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
2  Modulo.Collect.GraphicalConsole/AboutBox.cs
@@ -146,7 +146,7 @@ private void AboutBox_KeyPress(object sender, KeyPressEventArgs e)
146 146
147 147 private void lnkWebsite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
148 148 {
149   - System.Diagnostics.Process.Start("http://modsic.codeplex.com");
  149 + System.Diagnostics.Process.Start("https://github.com/modulogrc/modSIC");
150 150 }
151 151
152 152 private void ShowLicenseWindow(string textPath)
6 Modulo.Collect.GraphicalConsole/BooleanExternalVariableEditor.cs
@@ -28,7 +28,7 @@ public override Control GetEditor(string value)
28 28
29 29 private CheckBox ConfigureCheckBox(string value)
30 30 {
31   - CheckBox checkBox = new CheckBox() { Text = String.Format("{0}", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(this.externalVariable.comment)) };
  31 + CheckBox checkBox = new CheckBox() { Text = String.Format("{0}", this.externalVariable.comment) };
32 32 checkBox.Name = this.externalVariable.id;
33 33 checkBox.AutoSize = true;
34 34
@@ -50,7 +50,7 @@ private Panel ConfigureRadioButtons(string value)
50 50 panel.AutoSize = true;
51 51 panel.Name = this.externalVariable.id;
52 52
53   - Label label = new Label() { Text = String.Format("{0}", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(this.externalVariable.comment)) };
  53 + Label label = new Label() { Text = String.Format("{0}", this.externalVariable.comment) };
54 54 label.AutoSize = true;
55 55 label.Location = new Point(0, ControlY);
56 56 ControlY += 20;
@@ -66,7 +66,7 @@ private Panel ConfigureRadioButtons(string value)
66 66 ControlY += 25;
67 67
68 68 radio.Name = String.Format("{0}-{1}", this.externalVariable.id, possibleValue.Value);
69   - radio.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(possibleValue.hint);
  69 + radio.Text = possibleValue.hint;
70 70 radio.Tag = possibleValue.Value;
71 71
72 72 if (possibleValue.Value == value)
19 Modulo.Collect.GraphicalConsole/CollectionController.cs
@@ -122,7 +122,15 @@ public void Run(Object obj)
122 122 {
123 123 string collectRequestId;
124 124 var credentials = CreateCredentials(target);
125   - var ovalResults = RequestCollectionSynchronous(target.Address, credentials, ovalDefinitions, out collectRequestId, e.ExternalVariablesXml);
  125 +
  126 + Dictionary<string, string> targetParameters = null;
  127 + if (!String.IsNullOrEmpty(target.SSHPort))
  128 + {
  129 + targetParameters = new Dictionary<string, string>();
  130 + targetParameters.Add("sshPort", target.SSHPort);
  131 + }
  132 +
  133 + var ovalResults = RequestCollectionSynchronous(target.Address, credentials, ovalDefinitions, out collectRequestId, e.ExternalVariablesXml, targetParameters);
126 134 SaveOvalDocuments(ovalResults, collectRequestId);
127 135 }
128 136
@@ -145,11 +153,11 @@ private Credential CreateCredentials(TargetConfiguration target)
145 153 };
146 154 }
147 155
148   - private String RequestCollectionSynchronous(string address, Credential credentials, string ovalDefinitions, out string collectRequestId, string externalVariables = null, int interval = 10)
  156 + private String RequestCollectionSynchronous(string address, Credential credentials, string ovalDefinitions, out string collectRequestId, string externalVariables = null, Dictionary<string, string> targetParameters = null)
149 157 {
150 158 collectRequestId = null;
151 159
152   - var requestResult = modSicConnection.SendCollect(address, credentials, ovalDefinitions, externalVariables);
  160 + var requestResult = modSicConnection.SendCollect(address, credentials, ovalDefinitions, externalVariables, targetParameters);
153 161 if (requestResult.HasErrors)
154 162 {
155 163 view.ShowErrorMessage(requestResult.Message);
@@ -162,10 +170,7 @@ private String RequestCollectionSynchronous(string address, Credential credentia
162 170
163 171 while (true)
164 172 {
165   - if (interval > 0)
166   - {
167   - Sleep(interval);
168   - }
  173 + Sleep(10);
169 174
170 175 var statusString = this.IsCollectionInExecution(collectRequestId);
171 176 if (string.IsNullOrEmpty(statusString))
2  Modulo.Collect.GraphicalConsole/ConfigurationController.cs
@@ -111,6 +111,7 @@ public void view_OnWriteConfiguration(object sender, EventArgs e)
111 111 Section.target.Username = view.Target.Username ?? String.Empty;
112 112 Section.target.Password = view.Target.Password ?? String.Empty;
113 113 Section.target.AdministrativePassword = view.Target.AdministrativePassword ?? String.Empty;
  114 + Section.target.SSHPort = view.Target.SSHPort ?? String.Empty;
114 115
115 116 Section.file.SaveFolder = view.DestinationFolder ?? String.Empty;
116 117 Section.file.DefinitionFilename = view.DefinitionFilename ?? String.Empty;
@@ -154,6 +155,7 @@ public void view_OnReadConfiguration(object sender, EventArgs e)
154 155 view.Target.Username = target.Username;
155 156 view.Target.Password = target.Password;
156 157 view.Target.AdministrativePassword = target.AdministrativePassword;
  158 + view.Target.SSHPort = target.SSHPort;
157 159
158 160 var file = section.file;
159 161 view.DestinationFolder = file.SaveFolder;
16 Modulo.Collect.GraphicalConsole/ConfigurationSection.cs
@@ -136,12 +136,13 @@ public string Port
136 136
137 137 public class TargetConfigurationElement : ConfigurationElement
138 138 {
139   - public TargetConfigurationElement(string address, string username, string password, string administrativePassword)
  139 + public TargetConfigurationElement(string address, string username, string password, string administrativePassword, string SSHPort = null)
140 140 {
141 141 this.Address = address;
142 142 this.Username = username;
143 143 this.Password = password;
144 144 this.AdministrativePassword = administrativePassword;
  145 + this.SSHPort = SSHPort;
145 146 }
146 147
147 148 public TargetConfigurationElement() { }
@@ -197,6 +198,19 @@ public string AdministrativePassword
197 198 this["AdministrativePassword"] = value.ToString();
198 199 }
199 200 }
  201 +
  202 + [ConfigurationProperty("SSHPort", IsRequired = false)]
  203 + public string SSHPort
  204 + {
  205 + get
  206 + {
  207 + return (string)this["SSHPort"];
  208 + }
  209 + set
  210 + {
  211 + this["SSHPort"] = value.ToString();
  212 + }
  213 + }
200 214 }
201 215
202 216 public class FileConfigurationElement : ConfigurationElement
2  Modulo.Collect.GraphicalConsole/ExternalVariableController.cs
@@ -80,7 +80,7 @@ public void view_OnCreateControls(object sender, CreateControlsEventArgs e)
80 80 }
81 81 else
82 82 {
83   - var label = new Label() { Text = String.Format("{0}", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(variable.comment)) };
  83 + var label = new Label() { Text = String.Format("{0}", variable.comment) };
84 84 label.AutoSize = true;
85 85 Controls.Add(label);
86 86
158 Modulo.Collect.GraphicalConsole/MainWindow.Designer.cs
@@ -29,14 +29,19 @@ protected override void Dispose(bool disposing)
29 29 private void InitializeComponent()
30 30 {
31 31 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
32   - this.menuStrip1 = new System.Windows.Forms.MenuStrip();
  32 + this.chooserOval = new System.Windows.Forms.OpenFileDialog();
  33 + this.chooserFolder = new System.Windows.Forms.FolderBrowserDialog();
  34 + this.panel1 = new System.Windows.Forms.Panel();
  35 + this.logoPictureBox = new System.Windows.Forms.PictureBox();
  36 + this.panel2 = new System.Windows.Forms.Panel();
  37 + this.panel3 = new System.Windows.Forms.Panel();
  38 + this.btGo = new System.Windows.Forms.Button();
33 39 this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
34 40 this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
35 41 this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
36 42 this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
37 43 this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
38   - this.chooserOval = new System.Windows.Forms.OpenFileDialog();
39   - this.btGo = new System.Windows.Forms.Button();
  44 + this.menuStrip1 = new System.Windows.Forms.MenuStrip();
40 45 this.grTarget = new System.Windows.Forms.GroupBox();
41 46 this.label4 = new System.Windows.Forms.Label();
42 47 this.tbAdminPassword = new System.Windows.Forms.TextBox();
@@ -50,30 +55,73 @@ private void InitializeComponent()
50 55 this.btSaveDir = new System.Windows.Forms.Button();
51 56 this.label6 = new System.Windows.Forms.Label();
52 57 this.tbSaveFolder = new System.Windows.Forms.TextBox();
53   - this.logoPictureBox = new System.Windows.Forms.PictureBox();
54   - this.chooserFolder = new System.Windows.Forms.FolderBrowserDialog();
55 58 this.groupBox1 = new System.Windows.Forms.GroupBox();
56 59 this.lbDefName = new System.Windows.Forms.Label();
57 60 this.btChooseDefs = new System.Windows.Forms.Button();
58 61 this.label5 = new System.Windows.Forms.Label();
59 62 this.tbOvalDefs = new System.Windows.Forms.TextBox();
  63 + this.panel1.SuspendLayout();
  64 + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();
  65 + this.panel2.SuspendLayout();
  66 + this.panel3.SuspendLayout();
60 67 this.menuStrip1.SuspendLayout();
61 68 this.grTarget.SuspendLayout();
62 69 this.grResults.SuspendLayout();
63   - ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).BeginInit();
64 70 this.groupBox1.SuspendLayout();
65 71 this.SuspendLayout();
66 72 //
67   - // menuStrip1
  73 + // panel1
68 74 //
69   - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
70   - this.fileToolStripMenuItem,
71   - this.helpToolStripMenuItem});
72   - this.menuStrip1.Location = new System.Drawing.Point(0, 0);
73   - this.menuStrip1.Name = "menuStrip1";
74   - this.menuStrip1.Size = new System.Drawing.Size(642, 24);
75   - this.menuStrip1.TabIndex = 0;
76   - this.menuStrip1.Text = "menuStrip1";
  75 + this.panel1.Controls.Add(this.groupBox1);
  76 + this.panel1.Controls.Add(this.logoPictureBox);
  77 + this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
  78 + this.panel1.Location = new System.Drawing.Point(0, 24);
  79 + this.panel1.Name = "panel1";
  80 + this.panel1.Size = new System.Drawing.Size(514, 128);
  81 + this.panel1.TabIndex = 22;
  82 + //
  83 + // logoPictureBox
  84 + //
  85 + this.logoPictureBox.BackColor = System.Drawing.SystemColors.Window;
  86 + this.logoPictureBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
  87 + this.logoPictureBox.Dock = System.Windows.Forms.DockStyle.Top;
  88 + this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image")));
  89 + this.logoPictureBox.Location = new System.Drawing.Point(0, 0);
  90 + this.logoPictureBox.Name = "logoPictureBox";
  91 + this.logoPictureBox.Size = new System.Drawing.Size(514, 34);
  92 + this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  93 + this.logoPictureBox.TabIndex = 21;
  94 + this.logoPictureBox.TabStop = false;
  95 + //
  96 + // panel2
  97 + //
  98 + this.panel2.AutoSize = true;
  99 + this.panel2.Controls.Add(this.grTarget);
  100 + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
  101 + this.panel2.Location = new System.Drawing.Point(0, 152);
  102 + this.panel2.Name = "panel2";
  103 + this.panel2.Size = new System.Drawing.Size(514, 257);
  104 + this.panel2.TabIndex = 24;
  105 + //
  106 + // panel3
  107 + //
  108 + this.panel3.Controls.Add(this.grResults);
  109 + this.panel3.Controls.Add(this.btGo);
  110 + this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;
  111 + this.panel3.Location = new System.Drawing.Point(0, 277);
  112 + this.panel3.Name = "panel3";
  113 + this.panel3.Size = new System.Drawing.Size(514, 132);
  114 + this.panel3.TabIndex = 25;
  115 + //
  116 + // btGo
  117 + //
  118 + this.btGo.Location = new System.Drawing.Point(404, 85);
  119 + this.btGo.Name = "btGo";
  120 + this.btGo.Size = new System.Drawing.Size(100, 30);
  121 + this.btGo.TabIndex = 23;
  122 + this.btGo.Text = "Submit";
  123 + this.btGo.UseVisualStyleBackColor = true;
  124 + this.btGo.Click += new System.EventHandler(this.btGo_Click);
77 125 //
78 126 // fileToolStripMenuItem
79 127 //
@@ -113,18 +161,20 @@ private void InitializeComponent()
113 161 this.aboutToolStripMenuItem.Text = "&About...";
114 162 this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
115 163 //
116   - // btGo
  164 + // menuStrip1
117 165 //
118   - this.btGo.Location = new System.Drawing.Point(521, 275);
119   - this.btGo.Name = "btGo";
120   - this.btGo.Size = new System.Drawing.Size(99, 33);
121   - this.btGo.TabIndex = 21;
122   - this.btGo.Text = "Submit";
123   - this.btGo.UseVisualStyleBackColor = true;
124   - this.btGo.Click += new System.EventHandler(this.btGo_Click);
  166 + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
  167 + this.fileToolStripMenuItem,
  168 + this.helpToolStripMenuItem});
  169 + this.menuStrip1.Location = new System.Drawing.Point(0, 0);
  170 + this.menuStrip1.Name = "menuStrip1";
  171 + this.menuStrip1.Size = new System.Drawing.Size(514, 24);
  172 + this.menuStrip1.TabIndex = 0;
  173 + this.menuStrip1.Text = "menuStrip1";
125 174 //
126 175 // grTarget
127 176 //
  177 + this.grTarget.AutoSize = true;
128 178 this.grTarget.Controls.Add(this.label4);
129 179 this.grTarget.Controls.Add(this.tbAdminPassword);
130 180 this.grTarget.Controls.Add(this.label3);
@@ -133,10 +183,10 @@ private void InitializeComponent()
133 183 this.grTarget.Controls.Add(this.tbTargetUsername);
134 184 this.grTarget.Controls.Add(this.label1);
135 185 this.grTarget.Controls.Add(this.tbTarget);
136   - this.grTarget.Location = new System.Drawing.Point(12, 120);
  186 + this.grTarget.Location = new System.Drawing.Point(6, 0);
137 187 this.grTarget.Name = "grTarget";
138   - this.grTarget.Size = new System.Drawing.Size(492, 116);
139   - this.grTarget.TabIndex = 16;
  188 + this.grTarget.Size = new System.Drawing.Size(498, 119);
  189 + this.grTarget.TabIndex = 25;
140 190 this.grTarget.TabStop = false;
141 191 this.grTarget.Text = " Step 2: Select Target ";
142 192 //
@@ -212,19 +262,20 @@ private void InitializeComponent()
212 262 //
213 263 // grResults
214 264 //
  265 + this.grResults.AutoSize = true;
215 266 this.grResults.Controls.Add(this.btSaveDir);
216 267 this.grResults.Controls.Add(this.label6);
217 268 this.grResults.Controls.Add(this.tbSaveFolder);
218   - this.grResults.Location = new System.Drawing.Point(12, 242);
  269 + this.grResults.Location = new System.Drawing.Point(6, 3);
219 270 this.grResults.Name = "grResults";
220   - this.grResults.Size = new System.Drawing.Size(492, 66);
221   - this.grResults.TabIndex = 17;
  271 + this.grResults.Size = new System.Drawing.Size(498, 67);
  272 + this.grResults.TabIndex = 24;
222 273 this.grResults.TabStop = false;
223 274 this.grResults.Text = " Step 3: Choose Where to Save OVAL Results ";
224 275 //
225 276 // btSaveDir
226 277 //
227   - this.btSaveDir.Location = new System.Drawing.Point(411, 26);
  278 + this.btSaveDir.Location = new System.Drawing.Point(411, 25);
228 279 this.btSaveDir.Name = "btSaveDir";
229 280 this.btSaveDir.Size = new System.Drawing.Size(75, 23);
230 281 this.btSaveDir.TabIndex = 20;
@@ -249,26 +300,16 @@ private void InitializeComponent()
249 300 this.tbSaveFolder.Size = new System.Drawing.Size(304, 20);
250 301 this.tbSaveFolder.TabIndex = 18;
251 302 //
252   - // logoPictureBox
253   - //
254   - this.logoPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("logoPictureBox.Image")));
255   - this.logoPictureBox.Location = new System.Drawing.Point(515, 32);
256   - this.logoPictureBox.Name = "logoPictureBox";
257   - this.logoPictureBox.Size = new System.Drawing.Size(127, 45);
258   - this.logoPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
259   - this.logoPictureBox.TabIndex = 18;
260   - this.logoPictureBox.TabStop = false;
261   - //
262 303 // groupBox1
263 304 //
264 305 this.groupBox1.Controls.Add(this.lbDefName);
265 306 this.groupBox1.Controls.Add(this.btChooseDefs);
266 307 this.groupBox1.Controls.Add(this.label5);
267 308 this.groupBox1.Controls.Add(this.tbOvalDefs);
268   - this.groupBox1.Location = new System.Drawing.Point(12, 32);
  309 + this.groupBox1.Location = new System.Drawing.Point(6, 40);
269 310 this.groupBox1.Name = "groupBox1";
270   - this.groupBox1.Size = new System.Drawing.Size(492, 82);
271   - this.groupBox1.TabIndex = 19;
  311 + this.groupBox1.Size = new System.Drawing.Size(498, 82);
  312 + this.groupBox1.TabIndex = 22;
272 313 this.groupBox1.TabStop = false;
273 314 this.groupBox1.Text = " Step 1: Select an OVAL Definitions File ";
274 315 //
@@ -315,12 +356,11 @@ private void InitializeComponent()
315 356 //
316 357 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
317 358 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
318   - this.ClientSize = new System.Drawing.Size(642, 320);
319   - this.Controls.Add(this.groupBox1);
320   - this.Controls.Add(this.logoPictureBox);
321   - this.Controls.Add(this.grResults);
322   - this.Controls.Add(this.grTarget);
323   - this.Controls.Add(this.btGo);
  359 + this.AutoSize = true;
  360 + this.ClientSize = new System.Drawing.Size(514, 409);
  361 + this.Controls.Add(this.panel3);
  362 + this.Controls.Add(this.panel2);
  363 + this.Controls.Add(this.panel1);
324 364 this.Controls.Add(this.menuStrip1);
325 365 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
326 366 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@@ -329,13 +369,18 @@ private void InitializeComponent()
329 369 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
330 370 this.Text = "modSIC";
331 371 this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainWindow_FormClosed);
  372 + this.panel1.ResumeLayout(false);
  373 + ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit();
  374 + this.panel2.ResumeLayout(false);
  375 + this.panel2.PerformLayout();
  376 + this.panel3.ResumeLayout(false);
  377 + this.panel3.PerformLayout();
332 378 this.menuStrip1.ResumeLayout(false);
333 379 this.menuStrip1.PerformLayout();
334 380 this.grTarget.ResumeLayout(false);
335 381 this.grTarget.PerformLayout();
336 382 this.grResults.ResumeLayout(false);
337 383 this.grResults.PerformLayout();
338   - ((System.ComponentModel.ISupportInitialize)(this.logoPictureBox)).EndInit();
339 384 this.groupBox1.ResumeLayout(false);
340 385 this.groupBox1.PerformLayout();
341 386 this.ResumeLayout(false);
@@ -345,14 +390,19 @@ private void InitializeComponent()
345 390
346 391 #endregion
347 392
348   - private System.Windows.Forms.MenuStrip menuStrip1;
  393 + private System.Windows.Forms.OpenFileDialog chooserOval;
  394 + private System.Windows.Forms.FolderBrowserDialog chooserFolder;
  395 + private System.Windows.Forms.Panel panel1;
  396 + private System.Windows.Forms.PictureBox logoPictureBox;
  397 + private System.Windows.Forms.Panel panel2;
  398 + private System.Windows.Forms.Panel panel3;
  399 + private System.Windows.Forms.Button btGo;
349 400 private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
350 401 private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
351 402 private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
352 403 private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
353 404 private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
354   - private System.Windows.Forms.OpenFileDialog chooserOval;
355   - private System.Windows.Forms.Button btGo;
  405 + private System.Windows.Forms.MenuStrip menuStrip1;
356 406 private System.Windows.Forms.GroupBox grTarget;
357 407 private System.Windows.Forms.Label label4;
358 408 private System.Windows.Forms.TextBox tbAdminPassword;
@@ -366,8 +416,6 @@ private void InitializeComponent()
366 416 private System.Windows.Forms.Button btSaveDir;
367 417 private System.Windows.Forms.Label label6;
368 418 private System.Windows.Forms.TextBox tbSaveFolder;
369   - private System.Windows.Forms.PictureBox logoPictureBox;
370   - private System.Windows.Forms.FolderBrowserDialog chooserFolder;
371 419 private System.Windows.Forms.GroupBox groupBox1;
372 420 private System.Windows.Forms.Label lbDefName;
373 421 private System.Windows.Forms.Button btChooseDefs;
105 Modulo.Collect.GraphicalConsole/MainWindow.cs
@@ -38,6 +38,8 @@
38 38 using System.Windows.Forms;
39 39 using System.Collections.Generic;
40 40 using Modulo.Collect.OVAL.Definitions;
  41 +using System.Text;
  42 +using Modulo.Collect.OVAL.Helper;
41 43
42 44 namespace Modulo.Collect.GraphicalConsole
43 45 {
@@ -69,6 +71,8 @@ public void ShowErrorMessage(string text)
69 71 #endregion
70 72
71 73 #region Private Members
  74 + Label lbSSHPort = null;
  75 + TextBox txtSSHPort = null;
72 76 #endregion
73 77
74 78 #region Constructor
@@ -82,9 +86,64 @@ public MainWindow()
82 86 lbDefName.ForeColor = Color.Red;
83 87
84 88 ReadConfiguration();
  89 + ShowSSHPortWhenNecessary();
85 90 }
86 91 #endregion
87 92
  93 + #region SSH Port
  94 + private void ShowSSHPortWhenNecessary()
  95 + {
  96 + if (IsUnixDefinition(DefinitionFilename))
  97 + {
  98 + lbSSHPort = new Label() { Text = Resource.SSHPort, Parent = grTarget, Location = new Point() { X = 19, Y = 112 }, AutoSize = true };
  99 + txtSSHPort = new TextBox() { Parent = grTarget, Location = new Point() { X = 79, Y = 109 }, Size = new Size() { Width = 128, Height = 20 } };
  100 + if (!String.IsNullOrEmpty(Target.SSHPort))
  101 + {
  102 + txtSSHPort.Text = Target.SSHPort;
  103 + }
  104 + this.Size = new Size() { Width = 520, Height = 460};
  105 + }
  106 + else
  107 + {
  108 + if (lbSSHPort != null && txtSSHPort != null)
  109 + {
  110 + lbSSHPort.Parent = null;
  111 + txtSSHPort.Parent = null;
  112 +
  113 + lbSSHPort = null;
  114 + txtSSHPort = null;
  115 +
  116 + this.Size = new Size() { Width = 520, Height = 437 };
  117 + }
  118 + }
  119 + }
  120 +
  121 + public bool IsUnixDefinition(string filename)
  122 + {
  123 + if (!String.IsNullOrEmpty(filename))
  124 + {
  125 + var stream = GetStream(filename);
  126 + IEnumerable<string> errors = null;
  127 + var ovalDefinitions = oval_definitions.GetOvalDefinitionsFromStream(stream, out errors);
  128 + var x = new TargetPlatformDiscoverer(ovalDefinitions.objects);
  129 + var family = x.Discover();
  130 + if (family.ToString() == "unix")
  131 + {
  132 + return true;
  133 + }
  134 + }
  135 + return false;
  136 + }
  137 +
  138 + public virtual Stream GetStream(string filename)
  139 + {
  140 + string fileContent = File.ReadAllText(filename);
  141 + MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(fileContent));
  142 + return stream;
  143 + }
  144 +
  145 + #endregion
  146 +
88 147 #region Form Events
89 148 private void exitToolStripMenuItem_Click(object sender, EventArgs e)
90 149 {
@@ -172,6 +231,8 @@ private void btChooseDefs_Click(object sender, EventArgs e)
172 231 ShowSchemaWindow(args);
173 232 }
174 233 }
  234 +
  235 + ShowSSHPortWhenNecessary();
175 236 }
176 237 }
177 238
@@ -223,7 +284,7 @@ private void btGo_Click(object sender, EventArgs e)
223 284 Dialog.Error(Resource.InvalidServerConfiguration);
224 285 }
225 286 else if (String.IsNullOrEmpty(Target.Address) || String.IsNullOrEmpty(Target.Username)
226   - || String.IsNullOrEmpty(Target.Password))
  287 + || String.IsNullOrEmpty(Target.Password) || (txtSSHPort != null && String.IsNullOrEmpty(Target.SSHPort)))
227 288 {
228 289 Dialog.Error(Resource.InvalidTargetConfiguration);
229 290 }
@@ -299,6 +360,29 @@ private void ReadConfiguration()
299 360 }
300 361
301 362 tbSaveFolder.Text = DestinationFolder ?? String.Empty;
  363 + if (!ValidateSchema())
  364 + {
  365 + DefinitionFilename = String.Empty;
  366 + }
  367 + }
  368 +
  369 + private void WriteConfiguration()
  370 + {
  371 + if (Target != null)
  372 + {
  373 + Target.Address = tbTarget.Text;
  374 + Target.Username = tbTargetUsername.Text;
  375 + Target.Password = tbTargetPassword.Text;
  376 + Target.AdministrativePassword = tbAdminPassword.Text;
  377 + Target.SSHPort = txtSSHPort != null ? txtSSHPort.Text : null;
  378 + }
  379 + DestinationFolder = tbSaveFolder.Text;
  380 +
  381 + OnWriteConfiguration(this, EventArgs.Empty);
  382 + }
  383 +
  384 + private bool ValidateSchema()
  385 + {
302 386 if (File.Exists(DefinitionFilename))
303 387 {
304 388 var args = new SchemaEventArgs();
@@ -313,26 +397,11 @@ private void ReadConfiguration()
313 397 if (CheckExternalVariables(DefinitionFilename))
314 398 {
315 399 tbOvalDefs.Text = DefinitionFilename;
316   - return;
  400 + return true;
317 401 }
318 402 }
319 403 }
320   -
321   - DefinitionFilename = String.Empty;
322   - }
323   -
324   - private void WriteConfiguration()
325   - {
326   - if (Target != null)
327   - {
328   - Target.Address = tbTarget.Text;
329   - Target.Username = tbTargetUsername.Text;
330   - Target.Password = tbTargetPassword.Text;
331   - Target.AdministrativePassword = tbAdminPassword.Text;
332   - }
333   - DestinationFolder = tbSaveFolder.Text;
334   -
335   - OnWriteConfiguration(this, EventArgs.Empty);
  404 + return false;
336 405 }
337 406 #endregion
338 407 }
10 Modulo.Collect.GraphicalConsole/MainWindow.resx
@@ -117,12 +117,12 @@
117 117 <resheader name="writer">
118 118 <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119 119 </resheader>
120   - <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121   - <value>17, 17</value>
122   - </metadata>
123 120 <metadata name="chooserOval.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124 121 <value>132, 17</value>
125 122 </metadata>
  123 + <metadata name="chooserFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  124 + <value>251, 17</value>
  125 + </metadata>
126 126 <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
127 127 <data name="logoPictureBox.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
128 128 <value>
@@ -170,8 +170,8 @@
170 170 AgXRLoe9Op0pgYIoU5pV1i4lUBDtctir05kS+BcGKDfQldVbCQAAAABJRU5ErkJggg==
171 171 </value>
172 172 </data>
173   - <metadata name="chooserFolder.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
174   - <value>251, 17</value>
  173 + <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
  174 + <value>17, 17</value>
175 175 </metadata>
176 176 <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
177 177 <value>
11 Modulo.Collect.GraphicalConsole/Resource.Designer.cs
... ... @@ -1,7 +1,7 @@
1 1 //------------------------------------------------------------------------------
2 2 // <auto-generated>
3 3 // This code was generated by a tool.
4   -// Runtime Version:4.0.30319.237
  4 +// Runtime Version:4.0.30319.261
5 5 //
6 6 // Changes to this file may cause incorrect behavior and will be lost if
7 7 // the code is regenerated.
@@ -250,6 +250,15 @@ public class Resource {
250 250 }
251 251
252 252 /// <summary>
  253 + /// Looks up a localized string similar to SSH Port:.
  254 + /// </summary>
  255 + public static string SSHPort {
  256 + get {
  257 + return ResourceManager.GetString("SSHPort", resourceCulture);
  258 + }
  259 + }
  260 +
  261 + /// <summary>
253 262 /// Looks up a localized string similar to Trying to fetch OVAL documents..
254 263 /// </summary>
255 264 public static string TryingFetchOVALDocuments {
3  Modulo.Collect.GraphicalConsole/Resource.resx
@@ -180,6 +180,9 @@
180 180 <data name="ServerGeneratedID" xml:space="preserve">
181 181 <value>modSIC server generated an ID for this collection: {0}.</value>
182 182 </data>
  183 + <data name="SSHPort" xml:space="preserve">
  184 + <value>SSH Port:</value>
  185 + </data>
183 186 <data name="TryingFetchOVALDocuments" xml:space="preserve">
184 187 <value>Trying to fetch OVAL documents.</value>
185 188 </data>
1  Modulo.Collect.GraphicalConsole/TargetConfiguration.cs
@@ -44,5 +44,6 @@ public class TargetConfiguration
44 44 public string Username { get; set; }
45 45 public string Password { get; set; }
46 46 public string AdministrativePassword { get; set; }
  47 + public String SSHPort { get; set; }
47 48 }
48 49 }

0 comments on commit 3dfc2d9

Please sign in to comment.
Something went wrong with that request. Please try again.