CSCI E-143 CertPrep:   Additional notes at the end of the term

Saturday, Jan. 15, 2005

There is no assignment in Kalani for this week.   I want to give some additional material not in Kalani.  

The parenthesized references in this list are explained  here.   The underlined references might be the most useful, especially for a quick overview.

Information added at the end of the  Fall, 2004  semester

Command-line Utilities

Some command-line utilities are apparently showing up on the test.   Kalani doesn't talk about these at all,  but they are mentioned in other texts.

There is a list of about  40 of these things in the MSDN documentation,  at the entry named  ".NET Framework Tools".    I think you really ought to take a minute to look at it.

I was very surprised to find that these things had come up on the exam—first,  because they don't seem that important to me,  and second,  because no one has mentioned them until now.   You obviously shouldn't memorize details about these,  but you should know what each one does.   (Since I haven't seen any questions about these utilities,  I can't give you any more direction than that.)

caspol.exe

"The Code Access Security Policy tool enables users and administrators to modify security policy for the machine policy level,  the user policy level,  and the enterprise policy level."   (MSDN: "Code Access Security Policy Tool (Caspol.exe)")

Kalani uses the .NET Framework Configuration Tool  (Mscorcfg.msc)  to do this same work,  as we did in the brief class demo.   (There are several pages of description of this command in  Professional C#,  from Wrox Press).

caspol.exe  is a powerful and complicated program.   Here's the proof.   The following is what you get when you ask for help on this command:

Microsoft (R) .NET Framework CasPol 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Help screen requested

Usage: caspol <option> <args> ...

caspol -m[achine]
    Modifier that makes additional commands act on the machine level

caspol -u[ser]
    Modifier that makes additional commands act on the user level

caspol -en[terprise]
    Modifier that makes additional commands act on the enterprise level

caspol -cu
caspol -customuser <path>
    Modifier that makes additional commands act on the custom user level

caspol -a[ll]
    Set all policy levels as the active levels

caspol -ca
caspol -customall <path>
    Modifier that makes additional commands act on all levels as a custom user

caspol -l[ist]
    List code groups & permission sets

caspol -lg
caspol -listgroups
    List code groups

caspol -lp
caspol -listpset
    List permission sets

caspol -lf
caspol -listfulltrust
    List full trust assemblies

caspol -ld
caspol -listdescription
    List code group names and descriptions

caspol -ap
caspol -addpset { <named_xml_file> | <xml_file> <name> } 
    Add named permission set to policy level

caspol -cp
caspol -chgpset <xml_file> <pset_name>
    Change named permission set in active level

caspol -rp
caspol -rempset <pset_name>
    Remove a named permission set from the policy level

caspol -af
caspol -addfulltrust <assembly_name>
    Add full trust assembly to policy level

caspol -rf
caspol -remfulltrust <assembly_name>
    Remove a full trust assembly from the policy level

caspol -rg
caspol -remgroup <label|name>
    Remove code group at <label|name>

caspol -cg
caspol -chggroup <label|name> {<mship>|<pset_name>|<flag>}+
    Change code group at <label|name> to given membership,
    permission set, or flags

caspol -ag
caspol -addgroup <parent_label|name> <mship> <pset_name> <flag>
    Add code group to <parent_label|name> with given membership,
    permission set, and flags

caspol -rsg
caspol -resolvegroup <assembly_name>
    List code groups this file belongs to

caspol -rsp
caspol -resolveperm <assembly_name>
    List permissions granted to this file

caspol -s[ecurity] { on | off }
    Turn security on or off

caspol -e[xecution] { on | off }
    Enable/Disable checking for "right-to-run" on code execution start-up

caspol -pp
caspol -polchgprompt { on | off }
    Enable/Disable policy change prompt

caspol -q[uiet]
    Disable policy change prompt for this command

caspol -r[ecover]
    Recover the most recently saved version of a level

caspol -rs
caspol -reset
    Reset a level to its default state

caspol -f[orce]
    Enable forcing save that will disable caspol functionality

caspol -b[uildcache]
    Build the security policy cache file.

caspol -?
caspol /?
caspol -h[elp]
    Displays this screen


where "<mship>" can be:
  -allcode                 All code
  -appdir                  Application directory
  -custom <xml_file>       Custom membership condition
  -hash <hashAlg> {-hex <hashValue>|-file <assembly_name>}
                           Assembly hash
  -pub {-cert <cert_file_name> | -file <signed_file_name> | -hex <hex_string>}
                           Software publisher
  -site <website>          Site
  -strong -file <assemblyfile_name> {<name> | -noname}
          {<version> | -noversion}
                           Strong name
  -url <url>               URL
  -zone <zone_name>        Zone, where zone can be:
                                 MyComputer
                                 Intranet
                                 Trusted
                                 Internet
                                 Untrusted

where "<flag>" can be any combination of:
  -exclusive {on|off}
                           Set the policy statement Exclusive flag
  -levelfinal {on|off}
                           Set the policy statement LevelFinal flag
  -n[ame] <name>
                           Code group name
  -d[escription] <desc>
                           Code group description

permview.exe

This utility shows permissions for a specified module.

"One main reason that I like declarative  [rather than imperative]  security is that it's much easier to find out what an assembly wants to do.   The command-line .NET tool called  permview,  accessed as follows,  allows you to see all of the declarative permissions from an assembly:

permview /decl Book.dll
"If you use imperative security,  you're pretty much out of luck when trying to find out what a purchased assembly wants to do. . . . "     (Bock, p. 113)

Here is the result of asking the command for its help:   

Microsoft (R) .NET Framework Permission Request Viewer.  Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Usage: PermView [Options] 

Options:
  /OUTPUT   Dump output to a file.
  /DECL               Display declarative security on classes/methods.
  /HELP               Display this help text.

cordbg.exe

A debugger.   "If you want to experience all the joys of PC debugging circa 1985,  CORDBG.EXE's console-based debugging is all for you."       (Robbins, p. 244)

Before you can use this program,  your program must be compiled with the  /debug  switch.

To use this routine,  you start a session and then use subsequent  cordbg  commands.   There are examples of its use in the MSDN tutorials.      (MSDN: search for "cordbg")

Here is the command's help:

Microsoft (R) Common Language Runtime Test Debugger Shell Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.

Usage:  CORDBG [<program name> [<program args>]] [<CorDbg optional args>]
 The optional arguments are !prefixed command that you'd use while in cordbg
 You can escape the ! character by prefixing it with \
 E.g: cordbg foo.exe a 2 !b FooType.Foo::Main !g !x Foo.exe\!Something

The following commands are available:

ap[pdomainenum]     Display appdomains/assemblies/modules in the current process
a[ttach]            Attach to a running process
as[sociatesource]   Associate a source file with a breakpoint or stack frame
b[reak]             Set or display breakpoints
conn[ect]           Connect to a remote device
cont                Continue the current process
ca[tch]             Stop on exception, thread, and/or load events
dis[assemble]       Display native or IL disassembled instructions
del[ete]            Remove one or more breakpoints
du[mp]              Dump the contents of memory
d[own]              Navigate down from the current stack frame pointer
de[tach]            Detach from the current process
ex[it]              Kill the current process and exit the debugger
f[unceval]          Function evaluation
g[o]                Continue the current process
h[elp]              Display debugger command descriptions
i[n]                Step into the next source line
ig[nore]            Ignore exception, thread, and/or load events
k[ill]              Kill the current process
l[ist]              Display loaded modules, classes, or global functions
m[ode]              Display/modify various debugger modes
ns[ingle]           Step over the next native or IL instruction
n[ext]              Step over the next source line
news[tr]            Create a new string via function evaluation
newobjnc            Create a new object via function evaluation, no constructor
newo[bj]            Create a new object via function evaluation
o[ut]               Step out of the current function
pro[cessenum]       Display all managed processes running on the system
p[rint]             Print variables (locals, args, statics, etc.)
pa[th]              Set or display the source file search path
q[uit]              Kill the current process and exit the debugger
regd[efault]        Change the JIT debugger
r[un]               Start a process for debugging
re[sume]            Resume a thread
rem[ove]            Remove one or more breakpoints
reg[isters]         Display CPU registers for current thread
ref[reshsource]     Reload a source file for display
<                   Read and execute commands from a file
su[spend]           Suspend a thread
ss[ingle]           Step into the next native or IL instruction
so                  Step over the next source line
si                  Step into the next source line
s[tep]              Step into the next source line
sh[ow]              Display source code lines
set                 Modify the value of a variable (locals, statics, etc.)
setip               Set the next statement to a new line
stop                Set or display breakpoints
t[hreads]           Set or display current threads
>                   Write commands to a file
uw[here]            Display an unmanaged stack trace (Win32 mode only)
ut[hreads]          Set or display unmanaged threads (Win32 mode only)
uc[lear]            Clear the current unmanaged exception (Win32 mode only)
u[p]                Navigate up from the current stack frame pointer
?                   Display debugger command descriptions
wt                  Track native instruction count and display call tree
wr[itememory]       Write memory to target process
w[here]             Display a stack trace for the current thread
x                   Display symbols matching a given pattern

Information added at the end of the  Fall, 2003  semester

This stuff may seem vaguely familiar to you,  because I added it to the relevant course web pages during the Fall 2004 semester.

Two Classes not mentioned by Kalani

Information on SQL now found in the notes to either  Chapter 6, Part One  or  Chapter 6, Part Two

Information on XML now found in the  Additions to Kalani's Chapter 6


Good luck on the exam!


Last  revised  Jan. 15,  2005