2015年7月29日 星期三

WAPT Load Testing with JSON Format

好久不見了~ 大家都還好嗎?
最近真的忙到從「太陽哥」快變成「太陽餅」了!!! XD
因為最近公司的兩大事業群,都有跨足的專案,也剛好都有 Load Testing(負載測試)的需求。所以身為公司「殷殷美代子」的我,是時候該出動啦。
剛好可以利用這個機會將一些壓測心得,分享給大家。

廢話不多說,直接切入我們的正題「WAPT Load Testing with JSON Format」,不免俗地也是先來一張這節的圖解介紹:

這一節會用華文來解釋,因為有關 WAPT的華文相關文件真的有點少,所以在這節開始會適度的調整一下風格,盡量以華文來做說明。

Step 1: 下載官方測試版 JSON格式的模組。
直接下載:waptjsonmodule.exe

Step 2: 如果有開啟 WAPT Pro 3.5請先關掉,不然也會跳出視窗,要求先關掉主程式才能安裝的訊息。

Step 3: 在關掉主程式後,按兩下 JSON模組安裝程式後開始進行安裝。






Step 4: JSON模組安裝完成後,打開WAPT Pro 3.5主程式,到 Help> Modules Registration> All installed modules are registered 完成註冊。非註冊版可套用5為虛擬測試者或不超過20個腳本的測試者。(一個JSON模組要250鎂,大約是台幣7500塊左右)

Step 5: 在安裝完成 JSON模組後,會有2個內部設定用的新功能 JPath和 JSON Text 。

 Step 6: 打開之前錄製的腳本看 Response Body是用 Text格式,選擇 View as: Json就可以看得很清楚。


Step 7: 用 JPath的方法設定參數:
1. 在 Response processing按 Add

2. 在 Edit Variable的 Name設定變數名稱「result」(可參照 Response Body的 JSON格式來命名)
3. 在 Calculate the value of this parameter as the concatenation of the following functions: 按 Add

4. 在 Type: 選擇 JPath和 XPath: 輸入「/result」,在 Read JSON message from 選擇 "The server response to this request"(如果要選擇的資料來源是在之前所設定的變數,請選擇 Variable

5. 都做好設定後,可按一下 Test做擷取資料測試,檢查是否符合預期的 "值"

Step 8: 用 JPath的方法取得參數中的參數值:
1. 如果需要的值無法在一次參數中取得時,就會用此方法做二次取值法
2. 如同 Step 7的作法,在 Response processing按 Add

3. 在 Edit Variable的 Name設定變數名稱「ProjectID」(可參照 Response Body的 JSON格式來命名)
4. 在 Calculate the value of this parameter as the concatenation of the following functions: 按 Add

5. 在 Type: 選擇 Search parameter和 Index: 輸入「1」在 Left boundary輸入「ProjectID":」在 Right boundary輸入「,」在 Searches the選擇 Variable: 按 Select... 選擇之前所設定的變數「result」(左右兩邊的取值,可以參考之前「result」變數值做選擇「如下圖3」,也可以在取值後按 Test反覆測試直到取得所需的值)



6. 按 Test做取值測試,終於取得所要取代的變數值「ProjectID」(可以比較取得的值,是否跟 Response Body內的值相同)


Step 9: 套用變數的方法:
1. 選擇 Properties > POST Parameters 會看到改成變數的值 Name「projectId」和 Value「10209」按兩下

2. 檢查 Name:「projectID」在 Calculate the value of this parameter as the concatenation of the following functions:「10209」按兩下

3. 將 Text:「10209」改成變數值「$Var(ProjectID)」


4. 按一下 Test測試所擷取的值是否正確「10209」

Step 10: 設定變數值為「$Var(ProjectID)」的技巧:
1. 在 Properties按一下 Use Variable...選擇要取用的變數「ProjectID」

2. 會看到 URL Path: 多出的「$Var(ProjectID)」就是下面 Value設定要用到的變數值

Step 11: 結論:
取值設定變數的地方,多數都在「Response processing」>「Response Body」

帶入變數值的地方,多數都在「Properties」>「POST Parameters」

經過以上的說明,相信大家對於 WAPT的 JSON格式使用方式,應該有比較清楚的瞭解。
雖然沒有很完整的使用說明,不過應該足以應付基本應用上的需求。
以上都是在執行專案時會遇到的經驗談,如果各位真的有需要更詳細的說明,可以直接參考以下這個官網連結,也可以直接在此留言。
http://www.loadtestingtool.com/help/modules-json-jpath.shtml

這節的說明就先到這裡,我們下次見,掰掰!

~ See you ~

參考出處:
http://www.loadtestingtool.com/help/modules-json-jpath.shtml

2015年6月9日 星期二

源碼檢測 Visual Code Grepper

哈囉~ 大家好

今天我們就來聊一聊 —「源碼檢測 (Source Code Analysis)」的議題。

記得之前我們有談過「弱點掃描 (Vulnerability Scanning)」的部分,如果各位還記得的話,這個部份是比較屬於系統層面的弱點檢測,也是屬於「黑箱測試 (Black-Box Testing)」的範圍。而今天所要談到的源碼檢測也就是所謂的「程式碼掃描 (Code Review)」,這個部份是直接對程式碼做掃描,進而檢測出弱點並即時做程式碼的修正,這個範疇就是所謂的「白箱測試 (White-Box Testing)」。

一般做軟體程式開發時,研發人員在開發的過程中就會進行所謂的「單元測試 (Unit Test)」,在Alpha版 release 之前會就進行所謂的 Code Review,初次的程式碼掃描多數是由 RD 完成,到最後要 release 到 Beta版 前就會交由 QA 進行最後的 Source Code Analysis。因為大多數的程式開發人員,都沒有資訊安全的背景,所以做源碼檢測是有其必要性的。

而今天就要來介紹一個源碼檢測工具 —VCG(Visual Code Grepper),之所以會選擇這個工具的原因,不外乎它是一個 Freeware 免費軟體,再來就是它可以檢測的程式語言,包含支援 C/C++、C#、VB、PHP、Java、PL/SQL 等等,它所產出的測試報告除了可以明確指出有風險的程式碼之外,還可以提供建議的修正方法,並有圖表說明各種程度的風險所佔的百分比,還可以將掃描結果另存成文字檔,以提供正式測試報告說明使用。

以下就這一節的圖解說明:



Step 1: Download the installer from official website or File link as below.
VCG-Setup.msi
http://sourceforge.net/projects/visualcodegrepp/?source=typ_redirect

Step 2: After download file "VCG-Setup.msi" double click to install the tool.

Step 3: Welcome the VCG Setup Wizard. Click "Next"

Step 4: Select Installation Folder. If want to install to other folder click "Browse" to changed, if not please keep for default then click "Next"

Step 5: Confirm Installation click "Next"

Step 6: Click "Yes" to continue installation.


Step 7: Installation Complete click "Close"

Step 8: Check the Start menu then double click "VisualCodeGrepper" to start the tool GUI.

Step 9: Select Language to do the scanning click "OK" to show the main GUI.


Step 10: Select scanning language.
Settings | Java

Step 11: Select the scanning target folder or file.
File | New Target Directory... or New Target File...

Step 12: Select the target directory form your source code directory then click "OK" (Ex: select directory "TargetSourceCode")


Step 13: After loaded whole source code show like below.

Step 14: Run for full scan.
Scan | Full Scan


Step 15: After scanning complete then tick "Always display Visual Breakdown after every scan" and click "OK"

Step 16: Finished the scanning show the Code Breakdown like below.

Step 17: Results show like below.

Step 18: Select "Target File" show completed scanning target files and path.

Step 19: Select "Summary Table" show results summary sort by tables.



Step 20: Select more detailed text results sort by severity.
Scan | Sort Rich Text Results on Severity


Step 21: Select more detailed text results sort by file name.
Scan | Sort Rich Text Results on FileName


Step 22: Show comments to fix issues.
Scan | Show All 'FixMe' Comments


Step 23: Show results group by issues.
View | Group Rich Text Results by Issue


Step 24: Export and import results as XML or CSV formats.

Step 25: Save results as a text file.
File | Save Results as Text...





這一節介紹到這裡,各位對於這 VCG 源碼檢測工具,應該有了更進一步的瞭解。
特別對於檢測報告的解讀,應該可以透過不同選項來幫助使用者更容易找出問題,甚至提供建議的解決方法。

這套源碼檢測工具,雖然是 Freeware 但是功能性與準確性,並不輸給動輒幾百萬的商業檢測工具,唯一的差別應該只在商業工具會提供較完美的圖表測試報告。這當然是免費工具無法相提並論的。

今天我們就介紹到這裡,希望大家都能有所收穫。我們下次見~ 掰掰!

~ See you ~

參考出處:
http://sourceforge.net/projects/visualcodegrepp/