Search This Blog

Dec 2, 2023

Typescript with VS code notes

Header Placeholder

Normal Text place holder

  1. To add a different launch profile (i.e. run same source file with different settings, or specify a different start script etc.). Open launch.json file in editor, click on "Add Configuration" button. Resulting file below
        // Sample launch.json
        "version": "0.2.0",
        "configurations": [
            {
                "type": "node",
                "request": "launch",
                "name": "Run Dist/index.js",
                "program": "./dist/index.js",
                "envFile": "${workspaceFolder}/.env",
                "outFiles": [
                    "${workspaceFolder}/**/*.js"
                ]
            },
            {
                "type": "node",
                "request": "launch",
                "name": "Run testSMS.js",
                "program": "./dist/testSMS.js",
                "envFile": "${workspaceFolder}/.env",
                "outFiles": [
                    "${workspaceFolder}/**/*.js"
                ]
            }
        ]
    }
  2. Select a launch item to run
    1. Click "Run & Debug" button
    2. at top left corner, click on dropdown list besides green triangle, it should list 2 launch items listed in above sample file, one called "run index.js", the other called "run testsms.js".
    3. Select either one to run
  3. Any environment variables you specified in envFile above, you will have to define them as well in other running environments. For example, if you run the script from command line using "node.exe" then you have to "set env variables". If run in Azure app service, it should be defined under app service, configuration \ application settings section
  4. Bulletpoint placeholder
How to update a library
  1. Do NOT update the library source code in main program
  2. open a separate code window, make changes
  3. finish change and commit/sync
  4. "npm version patch" to update patch number. (or use other npm version  parameter to update minor version or major version)
  5. "npm publish" to publish it to NPM repository
  6. back to main program, 
    1. if package.json uses "^version#" in dependencies section, run "npm update", it should pull the latest version
    2. if package.json uses "version #" dependencies section, then edit the version# to be latest version, then remove library folder, and "npm install"

Nov 22, 2023

Demo - Regex

  •  any string as is but a particular string: ^(?!particularString$).*
  • Grouped match (it will return named group, give a host FQDN, below will return domainName   ^.*?\.(?<domainName>.*)
  • Matches duplicate line ^((?-s).+?)\R(?=(?s).*?^\1(?:\R|\z))
  • AD domain NETBIOS name when standalone
    [a-zA-Z0-9](?!.*[,:~!@#\$%\^'\.\(\)\{\}_ \/\\]).{0,14}\\
  • SAMaccountName
    ^(?!.*[\"\/\\\[\]:;|=,\+\*\?<>]).{1,19}$
  • AD domain NETBIOS name when followed by \userName (this also groups domain/user)
    ([a-zA-Z0-9](?![^\\]*[,:~!@#\$%\^'\.\(\)\{\}_ \/]).{0,14})\\((?!.*[\"\/\\\[\]:;|=,\+\*\?<>]).{1,19})
  • same for powershell match
    -match '^    ([a-zA-Z0-9](?![^\\]*[,:~!@#\$%\^''\.\(\)\{\}_ \/]).{0,14})\\((?!.*[\"\/\\\[\]:;|=,\+\*\?<>]).{1,19})'
  • DN --> OU path (stripping CN name)
    -match '^((.+?),)(OU=.*|CN=.*)' $OUPath = $matches[3]

Nov 20, 2023

Azure AD: Risky User VS. Risky Sign-in

 

Differences between “Risky Sign-In” and “Risk User”

  • Risky sign-in: abnormally in sign in activities, such as unusual location, impossible travels etc.
  • Risky user: An account that MS believes to have high probability of having been comprised (e.g. leaked credential)

 

More importantly, the difference lies in how they are dealt with:

  • Risky Sign-in: requires additional authentication (e.g. MFA)
  • Risky User: Make old credential invalid (e.g. reset password)

 

If we are to target “Risky Users”, Risky User Policy can be used to force password change. 

 

Similarly, If we are to target “Risky Sign Ins”, we can use “Risky Sign in Policy” to enforce MFA.