HP Fortify scans get ASP Pre-Compilation error - asp.net

I am using Visual Studio 2012 and HP Fortify 4.21 with the latest rule packs.
The code (C#) lives on the same machine that has HP Fortify and I am only using AWB not SCC. The code successfully builds when the developer does the build, but when I try to scan with Fortify I get an error.
ASP Pre-compilation error
This error happens whether I am launching from VS or from command line. The logs show no errors or warnings, but stating at the end that there is nothing to store, so a fpr file is never created. If I run the scan from Audit Workbench it crashes only stating that it cannot create the build ID.
I did find a suggestion (below) to resolve the ASP issue but it fails and does not create the fpr file to be able to run the last line (to do the scan).
I appreciate any assistance!
Step 1: Clean
sourceanalyzer -b "Build ID" -clean
Step 2: Translation/Build
sourceanalyzer -b "Build ID" -Xmx1280M -Xss8M -debug -logfile trans.log devenv "Sample.sln" /Rebuild Debug
Step 3: Analysis
sourceanalyzer -b "Build ID" -Xmx1280M -Xss8M -debug -logfile scan.log -scan -f Results.fpr

I was running into this issue and this took care of my problem.
Step 1. Click the "BUILD" tab
Step 2. Click "Clean Solution"
Step 3. Most likely two folders appeared in the Solution Explorer (bin and obj). Right click each one and delete it, doesn't matter what order you do it in.
Step 4. Click the "BUILD" tab
Step 5. Click "Rebuild Solution"
Step 6. Try to run FORTIFY again
Extra steps
Step 7. If it still doesn't work check your web.config for errors. The project will build with errors but will cause the precompilation to fail with Fortify.
Step 8. Try allocating more RAM to Fortify by going to HP Fortify -> Options -> Project Settings -> Memory (MB) -> 1024 (or higher).

I've run into similar problems. Try it on another machine. Sometimes that makes it work. When it hasn't it has been due to a Fortify bug. Working with Fortify support has helped me track the problem down. HP files a bug on it though I don't believe it helps. That said, once I know what construct in the file has caused the failure I've been able to modify the file to get Fortify to complete.
Sorry I don't have more help.

The problem is with one or more of your ASPX files. For dotnet web forms the ASPX pages are not compiled by Visual Studio, they are compiled dynamically on the server. In order for Fortify to scan that code, it is calling the ASPNET_compiler to compile your ASPX files. Pass -debug from the command line and then look in the log for a call to ASPNET_compiler. You can copy those arguments and then run them in the Visual Studio command prompt to find the ASPX file that is causing the problem. Keep in mind that when passing ASPNET_compiler a directory to compile, it dies when it finds the first error. You may have to run it a few times to find all of the errors.

Check the Analysis Information Tab in AWB for a related scan error. Also look at the scan log file for a related entry there as well.
If Eric is correct, you may want to put sourceanalyzer into the build script in case the problem re-appears.

step 1. - click "build" tab
step 2. - click "clean solution"
step 3. - 2 folders appeared in solution explorer (bin , obj). right click
each 1 , delete it, doesn't matter order in. step 4. click "build" tab step 5. click "rebuild solution" step 6. try run fortify again
extra steps
step 7. - f still doesn't work check web.config errors. project build errors cause precompilation fail fortify.
step 8. - try allocating more ram fortify going hp fortify -> options -> project settings -> memory (mb) -> 1024 (or higher).
The below link helped to solve my problems.
http://nayviocde12.blogspot.be/2012/08/aspnet-hp-fortify-scans-get-asp-pre.html

Fortify SCA version 16.20 and after
Starting with Fortify SCA version 16.20, ASP.Net code no longer uses the Microsoft aspnet_compiler.exe so this particular issue will not occur again.
Before Fortify SCA version 16.20
My preferred method of debugging precompiler issues is to add this command into the post-build event of the web project in Visual Studio, that way the error shows up in the error list.
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler.exe" -v / -p $(ProjectDir)
Another thing to keep in mind, if you have files that are not part of the solution but are part in the web projects directory, the aspnet_compiler will still read them.
I find this situation common when developers would excluded files from Visual Studio. This does not delete them. Or if they delete them, then delete through the Visual Studio interface but not from the underlying source code repository and they just get downloaded again on checkout.
An easy way to check this would be to turn on Show All Files in the Visual Studio Solution Explorer window.

Related

How to convert from VS web deploy to command line MS deploy

Within Visual Studio, I use Web Deploy.
Within the settings, it asks for 4 fields to be filled one (and 1 optional)
I am guessing, behind the scenes, it is calling msdeploy.exe and passing them as command line arguments
I'm struggling to map these across as I want to use
shell: cmd
run: '"C:/Program Files (x86)/IIS/Microsoft Web Deploy V3/msdeploy.exe"
-verb:sync
-allowUntrusted
-source:contentPath="%CD%\myDomain.Ui\bin\Release\netcoreapp3.1\"
-dest:contentPath=domain,computerName="<server>:443/msdeploy.axd?site=<site name>",username="<user name>",password="<password>",authtype="Basic"'
As you can see, source:contentPath uses the actual path and this works fine in GitHub actions. I'm having issues with the dest: part. In the example above, I've used the titles (so instead of myUserName, I've used as it shows in the screenshot)
I have 2 questions.
When I click "publish" within Visual Studio, if it really is just calling msdeploy.exe, then is it possible to show this in the output. If I knew how to do that, I may be able to answer my own question
Have I mapped them correctly
As for how to see more details, this KIND OF works:
Visual studio 2017 Verbose publish
The relevant part is
To change the amount of information included in the build log On the menu bar, choose Tools, Options.
On the Projects and Solutions page, choose the Build and Run page.
In the MSBuild project build output verbosity list, choose one of the following values, and then choose the OK button.
And then, at the very end of the build, search for MsDeploySourceProviderSetting
You can then see the details! This gives some of the values, but not all!! It doesn't really answer the question! However, it got me part way there
It needed to be
-dest:contentPath=<site name>,computerName="<server>:443/msdeploy.axd?site=<site name>",username="<user name>",password="<password>",authtype="Basic"'
EG, my website ULR is https://example.com and in IIS, it is set up as MyWebsite
-dest:contentPath=<MyWebsite>,computerName="https://examplecom:443/msdeploy.axd?site=MyWebsite",username="<user name>",password="<password>",authtype="Basic"'
Also, if you do use VS as I did, it may give you a different port, so be aware that 443 may not be right!!

How can we redirect 'RobotTempDir' folder to save at different location on windows 10?

I am working with Robot Framework using RED editor on Eclipse IDE. When i ran a Robot test case an error as shown in the screenshot has occurred
Upon tracing back my actions, I have noticed that RobotTempDir... got deleted from Temp folder. I restored that folder and ran the test case. Then it executed successfully.
In future there are chances that while cleaning temp folder contents, RobotTempDir... may get deleted unknowingly. Is there a way to redirect this RobotTempDir... contents to save in a different location?
I looked into the C:\Python36\Lib\site-packages\robot path and didn't find any files where i can change/update Robot temp folder details.
The TestRunnerAgent.py is not part of the Robot Framework application but instead comes with the RED plugin. It is part of their Robot Run functionality which allows it to retrieve information from Robot Framework while it is running.
This information is then displayed in the Eclipse Message Log panel or used when using the RED debugger functionality.
In my view this file is generated every time Eclipse is started and I think the only time this error would occur is when that file/folder is deleted while Eclipse is running. Restarting Eclipse should fix this.
TestRunnerAgent.py is custom listener which is attached to Robot process to report back to RED what is happening during test execution. For normal test runs,this is Execution View information,also Message Log stuff printed there. For Debug run, TestRunnerAgent.py allows to control execution process (breakpoint stop,stepping) and changing internals of Robot (state of variables).
It is embedded in RED package,and as you said, it is temporary placed in Temp dir for execution. If you would like to check source,either check jar file: org.robotframework.ide.core-functions-0.0.1-SNAPSHOT.jar or on GitHub: https://github.com/nokia/RED/tree/master/src/RobotFrameworkCore/org.robotframework.ide.core-functions/src/main/python/scripts
Back to your issue:
RED starts Robot execution with following command:
<selected python interpreter> -m robot.run --listener <path to TestRunnerAgent.py> <details what to run and other miscs>
There is no indication of error such error in TestRunnerAgent.py although there is in RobotLaunchConfigurationDelegate.java which tries to start Robot using interpreter in current Project configuration. I assume that there is something wrong in your env setup (either in RED or in OS)
I would suggest to check following:
check if you selected proper python interpreter with installed Robot (from Windows->Preferences-> RobotFramework ->Interpreters
check if your project looks similar as here: http://nokia.github.io/RED/help/user_guide/quick_start.html
you can try to use custom script to catch robot execution command and remove --listener part to validate if this is the culprit: http://nokia.github.io/RED/help/user_guide/launching/local_launch_scripting.html
there should be command in Console View - try to run it by yourself

Asp.Net 5 - On the fly compilation

I just got an ASP.NET 5 Web API Application running in Visual Studio code by following this guide and I can launch the application by executing the command "dnx . web". How can I make the application build on the fly when I make changes to the source file ?
Update - This seems to be an open issue. Link 1, Link 2
dnx . web --watch is the command that you are looking for.
However, there is a caveat when you do that from command line: when a file changes, the server is stopped.
When you do the same from VS 2015, VS knows how to restart the server when it stops.
I noticed I had the same problem, and it seems to work more or less as expected if you run your site without the debugger attached.
I think the debugger is more sensitive to changes in cs files, and does't want them to change while it's trying to trace/step through them.
At first I thought it was related to the CLR type you use to run it, but I can change that and it works as long as youre not debugging.

Error MSB3025: using CruiseControl.net - Builds fine from command prompt

I'm hoping someone has seen this error before. I'm using MSBuild with CruiseControl.Net to run the build for this project. When i run the build from the command prompt it actually builds without errors, but when i run it with CruiseControl.net i get the following error:
error MSB3025: The source file "C:\PE\PE-DEV\UIProjects\FolderName\" is actually a directory. The "Copy" task does not support copying directories.
6 Warning(s)
1 Error(s)
Time Elapsed 00:01:50.07
I have been doing a search and nothing with that error number shows up in google. Any help will be greatly appreciated.
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\PE\PE-DEV</workingDirectory>
<projectFile>Solution.sln</projectFile>
<buildArgs>/p:Configuration=DeployDev;BuildMode=DRYRUN;CreatePackage=true /fileLogger /verbosity:normal</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
This task works fine in other projects... If i use command prompt and run msbuild it works fine as well.
If it works when you run it from the command prompt (runs using your user account and permissions) and fails when running under CC (runs under whatever service account cc is running) it might be a permission issue. Try changing the account that cc.net runs under to your own account and see what happens.
This one was a tricky one, i was able to make the project work. The issue was the deploy build xml file had a typo somewhere and i was able to find the bug and fix it and now the project is building as it should.

Why won't my VS 2005 hit the break points?

I'm going crazy and wasting a lot of time. I am running in DEBUG, checked the web.config to ensure debug=true is there, checked the code to ensure I am reaching it, cleared all temp files and pdb's. The only thing that works is to continually kill the solution, create a new solution and add all the projects again. I shouldn't have to do this every day.
If you're using Windows Vista, try launching Visual Studio as an Administrator. Even if you're already running as an Administrator on the machine, still right-click on Visual Studio and select "Run as Administrator."
Right-click the solution node in solution explorer end select Properties. Check the configuration settings in there.
If you are attaching to a process sometimes this can be caused by symbols not being loaded. If you see the code skip over your breakpoint hover over the breakpoint it will tell you if symbols were not loaded. If that is the case Here are several potential solutions to your problem.
Clear out all files in C:\Windows\Microsoft.NET\Framework\v2.0.50727\ASP.Net temp files.
Ensure you deployed the *.pdb files to the bin folder of your application.
The web process has not loaded your assemblies at the time you attach your debugger. Reset the process and wait a little longer before attaching to the process to give the process a chance to load your dll's.
Actually your visual Studio is not attaching your project with process WebDev.WebServer.EXE
Do the following Steps:
click on Debug Menu
Click on Attach to process WebDev.WebServer.EXE
Now your Debugging is enabled.

Resources