nodes – How to embed image field url in API response?

I have a content type that has a title, body, link, and image field.
Then in my php file I have the following:

$articles = Drupal::entityTypeManager()->getStorage('node')->loadByProperties(('type' => 'expand_your_world', 'status' => 1));

When I check the articles variable in a JSON response, I only see the title, body, and link.

I then concluded that probably the reason why the image is not included, is because it is a reference field.

My get method looks like this:

$articles = Drupal::entityTypeManager()->getStorage('node')->loadByProperties(('type' => 'expand_your_world', 'status' => 1));

$main_content = ();

foreach($articles as $article) {
    $fields = (
        'title' => $article->title(0)->value,
        'body' => $article->body(0)->value,
        'field_expand_link' => $article->field_expand_link(0)->uri,
        'field_expand_icon' => '',
    );

    array_push($main_content, $fields);

}

$response = (
    'content' => $articles,
    
);

How do I embed the image URL in the response?

entities – How to I embed image field url in API response

I have a content type that has a title, body, link, and image field.
Then in my php file I have the following:

$articles = Drupal::entityTypeManager()->getStorage('node')->loadByProperties(('type' => 'expand_your_world', 'status' => 1));

When I check the articles variable in a JSON response, I only see the title, body, and link.

I then concluded that probably the reason why the image is not included, its because it is a reference field.

My get method looks like this:

$articles = Drupal::entityTypeManager()->getStorage('node')->loadByProperties(('type' => 'expand_your_world', 'status' => 1));

$main_content = ();

foreach($articles as $article) {
    $fields = (
        'title' => $article->title(0)->value,
        'body' => $article->body(0)->value,
        'field_expand_link' => $article->field_expand_link(0)->uri,
        'field_expand_icon' => '',
    );

    array_push($main_content, $fields);

}

$response = (
    'content' => $articles,
    
);

How do I embed the image URL in the response?

webgoat – What is happening to second response in HTTP Splitting?

Doing the webgoat HTTP splitting exercise. I feel like I’m doing something wrong or there is something that I don’t understand.

The idea is that since we can control the referer parameter, we can split the request into 2 and have the server sends us another response (This could later on be used to trick victims into caching our 2nd response with the expires parameter).

The thing is: I am not seeing anything. On the browser or on Burp suite.

I am trying the following payload (By intercepting the POST request after clicking “Search!” and replacing the sent string inside the html form box with the following):

test%0aContent-Length:%200%0a%0aHTTP/1.1%20200%20OK%0aContent-Type:%20text/html%0aContent-Length:%2017%0a<html>pwnd</html>

On Burpsuite I see the 302 and the following 200 with the payload appearing at the end of the path and that’s it. Supposedly based on what I am reading on the solution tab, I should be redirected to a site with the html I injected.

Any idea what I might be doing wrong or what’s happening?

javascript – Why mongo db response value before update

I need to update collection and return updated value. My code is:

const someFunction = async () => {
  const { value } = await dataStore.customerSettings.findOneAndUpdate(
            { organizationId }, 
            { $push: { archivedSuppliers: archivedSupplier } }
          );
  return value;
}

Problem is that the value is equal to collection object before update. Why is it? And how to get updated value?

amazon web services – Ajax not receiving return data from server response

I work with an open source package call OpenEMR https://github.com/openemr/openemr/.

I am having a problem with the ACL display screen. It displays this error message.
ERROR, unable to collect data from server

This is a link to the code in reference.
https://github.com/openemr/openemr/blob/2e1087e3c371ee08268cd1e7777c6a76b10e7cfa/interface/usergroup/adminacl.php#L214

I have set traps on the server. The server is send/echoing out the XML. I have captured the XML in a file on the server. So, I know that server side is processing the request and sending a response.

//PROCESS USERNAME REQUESTS
if ($_POST("control") == "username") {
  if ($_POST("action") == "list") {
     //return username list with alert if user is not joined to group
      echo username_listings_xml($error);
   }
}

https://github.com/openemr/openemr/blob/2e1087e3c371ee08268cd1e7777c6a76b10e7cfa/library/ajax/adminacl_ajax.php#L51

The response is not making it back to the client. How do I troubleshoot the response from the server to the client? What could block the server response from reaching the client?

The server is on AWS and is Ubuntu 20.04. PHP 7.4 Apache 2.x.

Where should I be looking to fix this issue?

c# – 6988 response returned while trying to establish secure messaging

I’m Trying to establish ISO secure messaging between interface device and Java smart card according to ISO 7816-4 which is a requirement for authenticate personalization.

The card support Java card 3.0.5 / Global platform 2.3 with SCP02. I am able to authenticate with ISD by the mean of GP authentication and trying to establish ISO secure messaging, but unfortunately with no luck as the card keep returning 6988 (SM-DO-incorrect).

the following is trace log for step by step what I am currently doing, Maybe some one can help me to detect what I did wrong or advise me what need to be done with thanks.

 Set Security Environment - MSE Perso OID 

(TRACE) APDU Buffer(0022C1A406800109830108) => Response(9000)
                                    

                                   AUTHENTICATION AND ESTABLISHMENT OF SESSION KEYS Start.

(TRACE) 1. Request an 8 byte random number IC 
(TRACE) APDU Buffer(0084000008) => Response(6A0D494142B1E1319000)
(TRACE)      RND.IC =  6A0D494142B1E131
(TRACE) 2. Generate an 8 byte random and a 16 byte random
(TRACE)      RND.IFD =  0D851519BAD4164D
(TRACE)      KIFD =  40C60DA70EE38D09A892DEB496E892ED
(TRACE) 3. Concatenate RND.IFD, RND.IC and KIFD
(TRACE)      S =  0D851519BAD4164D6A0D494142B1E13140C60DA70EE38D09A892DEB496E892ED
(TRACE) 4. Encrypt S with 3DES key KEnc
(TRACE)      EIFD = 6919119AA8695E134B51D3BBF74220B07DA63F641523BCDB77817DCB0209F6D5
(TRACE) 5. Compute MAC over EIFD with 3DES key KMAC
(TRACE)      MIFD = FD2F7F08A9386738
(TRACE) 6. Construct and send command data for EXTERNAL AUTHENTICATE
(TRACE)      cmd_data = 6919119AA8695E134B51D3BBF74220B07DA63F641523BCDB77817DCB0209F6D5FD2F7F08A9386738
(TRACE) APDU Buffer(00820000286919119AA8695E134B51D3BBF74220B07DA63F641523BCDB77817DCB0209F6D5FD2F7F08A938673800) => Response(31A0CD97BAFFB04679E88CF797ABDB5FD00D0C5D98153A9935F2AD65B020957CE4537D9F87879BA49000)
(TRACE)      Recived Data = 31A0CD97BAFFB04679E88CF797ABDB5FD00D0C5D98153A9935F2AD65B020957CE4537D9F87879BA4
(TRACE) 7. Verify MAC
(TRACE)      - Recived MAC E4537D9F87879BA4
(TRACE)      - Calculated MAC E4537D9F87879BA4
(TRACE)      Verify MAC Succesfully.
(TRACE) 8. Decrypt and compare received data
(TRACE)      Decrypted Data = 6A0D494142B1E1310D851519BAD4164DA8F85FAE9698174CA2BE68608CF0FBE1
(TRACE)      - Card Challenge (RIC) 6A0D494142B1E131
(TRACE)      - Received HostChallenge 0D851519BAD4164D
(TRACE)      - Received Card Key (KIC) A8F85FAE9698174CA2BE68608CF0FBE1
(TRACE) 9. Verify Recived RND.IFD with generated RND.IFD
(TRACE)      - Recived RND.IFD 0D851519BAD4164D
(TRACE)      - Generated RND.IFD 0D851519BAD4164D
(TRACE)      Verified Succesfully..
                                    

                                   Key Derivation Process Start..

(TRACE) 10. Calculate XOR of KIFD and KIC
(TRACE)      - KIFD Key = 40C60DA70EE38D09A892DEB496E892ED
(TRACE)      - KIC  Key = A8F85FAE9698174CA2BE68608CF0FBE1
(TRACE)      XOR Keys (Seed) = E83E5209987B9A450A2CB6D41A18690C
(TRACE) 11. Compute encryption key (c = 00000001)
(TRACE)      Concatenate Kseed and c (D) = E83E5209987B9A450A2CB6D41A18690C00000001
(TRACE) 12. Calculate the SHA-1 hash of D
(TRACE)      HSHA-1(D) = 0A30A42CCCB2ED7BFF1A27D3A33BEF615140F85E
(TRACE) 13. Get 16 byte of Hash as a Session Key for Encryption
(TRACE)      SKeyEnc = 0A30A42CCCB2ED7BFF1A27D3A33BEF61
(TRACE) 14. Derive Ka and Kb from SKeyEnc
(TRACE)      SKeyEnc - Ka = 0A30A42CCCB2ED7B
(TRACE)      SKeyEnc - Kb = FF1A27D3A33BEF61
(TRACE) 15. Adjust parity bits
(TRACE)      SKeyEnc - Ka Adjusted = 0B31A42CCDB3EC7A
(TRACE)      SKeyEnc - Kb Adjusted = FE1A26D3A23BEF61
(TRACE) 16. Compute MAC computation key (c = 00000002)
(TRACE)      Concatenate Kseed and c (D) = E83E5209987B9A450A2CB6D41A18690C00000002
(TRACE) 17. Calculate the SHA-1 hash of D
(TRACE)      HSHA-1(D) = 1003F1D52F09105A7C85D88590B6473673C2BEE1
(TRACE) 18. Get 16 byte of Hash as a Session Key for MAC
(TRACE)      Skeymac = 1003F1D52F09105A7C85D88590B64736
(TRACE) 19. Derive Ka and Kb from SKeyEnc
(TRACE)      SMackey - Ka = 1003F1D52F09105A
(TRACE)      Skeymac - Kb = 7C85D88590B64736
(TRACE) 20. Adjust parity bits
(TRACE)      SMackey - Ka Adjusted = 1002F1D52F08105B
(TRACE)      SMackey - Kb Adjusted = 7C85D98591B64637
                                    

                                     Generate Sequence Counter

(TRACE)      Card Challenge is 6A0D494142B1E131
(TRACE)      HostChallenege is 0D851519BAD4164D
(TRACE)      SSC =  42B1E131BAD4164D
                                        
                          

     Start Secure Channel..

                                        

                                   PutErrorsMap - MapIsoError 

(TRACE)      PLAIN APDU COMMAND (00DA01B60A6A86628269836983698400)
                                        

                                   Constructing Protected APDU....

(TRACE) 1. Add Mask to CLA and add header Padding.
(TRACE)      CmdHeader = 0CDA01B680000000
(TRACE) 2. Pad Data
(TRACE)      Data = 6A866282698369836984800000000000
(TRACE) 3. Encrypt data with KSEnc (0A30A42CCCB2ED7BFF1A27D3A33BEF61)
(TRACE)      EncryptedData = A7448FC08AD1B16F1DDC32E5E30031A2
(TRACE) 4. Build DO‘87’
(TRACE)      DO87 = 871101A7448FC08AD1B16F1DDC32E5E30031A2
(TRACE) 5. Concatenate CmdHeader and DO‘87’
(TRACE)      M = 0CDA01B680000000871101A7448FC08AD1B16F1DDC32E5E30031A2
(TRACE) 6. Increase Sequence Counter, New Value is : 42B1E131BAD4164E
(TRACE) 7. Build DO‘97’
(TRACE)      DO97 = 970100
(TRACE) 8. Concatenate SSC and M and DO97
(TRACE)      N = 42B1E131BAD4164E0CDA01B680000000871101A7448FC08AD1B16F1DDC32E5E30031A2970100
(TRACE) 9. add padding
(TRACE)      N = 42B1E131BAD4164E0CDA01B680000000871101A7448FC08AD1B16F1DDC32E5E30031A29701008000
(TRACE) 10. Compute MAC over N with KSMAC (1003F1D52F09105A7C85D88590B64736)
(TRACE)      CC = 4F1AE0D9B18340E5
(TRACE) 11. Build DO‘8E’
(TRACE)      DO8E = 8E084F1AE0D9B18340E5
(TRACE) 12. Construct and send protected APDU
(TRACE)      ProtectedAPDU = 0CDA01B620871101A7448FC08AD1B16F1DDC32E5E30031A29701008E084F1AE0D9B18340E500
(TRACE) APDU Buffer(0CDA01B620871101A7448FC08AD1B16F1DDC32E5E30031A29701008E084F1AE0D9B18340E500) => Response(6988)

Any help will be appreciated.

Thanks

forms – How to handle blocking UI elements while waiting for server response

Lately I’ve been using React + Formik to create great user experiences.
I’ve a question about blocking the UI when the XHR is still processing.

Imagine a register form with only a sign up button. As soon as the button is clicked I disable the button, it show a loader and sets the cursor to default. All good so far.

In that same view of the webpage there is also a link to “Already have an account? Sign In!” (and a fiew other hrefs). The “Sign In!” part is an URL, which is still clickable. What do I do in this situation? Should I block the “Sign In” link from being clicked?

Because when the user clicks “Sign In!” when no response has been received yet from the backend it either returns 200 registering was successful and redirects. Or it returns a validation error in which case the component is unmounted and React gives errors.

settings – Slow touch/swipe response on Lenovo Tablet P11

I recently purchased Lenovo Tablet P11 and I must say it’s a great tablet with one exception. The scrolling and swiping in it is not so sensitive. I noticed I need to drag my finger for one centimeter until it registers the swipe.

I tried animation settings in dev options and I turned on pointer location so I know that screen actually sees all the touches pretty well. That makes me think that it’s software issue.

I was curious if anyone encountered such problem on P11 or other devices? Maybe someone knows how to improve it.

Thank you!

When uploading a file on Google Forms, I would like the file uploads to go into a custom folder based on the form response (their name)

Ex. someone submitting the form with a file upload and on form submit it creates a custom folder based on their form response (their name) on google drive with their submission in it.

Using this script, I can put all files into one folder, but I don’t know enough about script to know where to change what the folder is named

const PARENT_FOLDER_ID = "<<Folder ID here>>";

const initialize = () => {
  const form = FormApp.getActiveForm();
  ScriptApp.newTrigger("onFormSubmit").forForm(form).onFormSubmit().create();
};

const onFormSubmit = ({ response } = {}) => {
  try {
    // Get a list of all files uploaded with the response
    const files = response
      .getItemResponses()
      // We are only interested in File Upload type of questions
      .filter(
        (itemResponse) =>
          itemResponse.getItem().getType().toString() === "FILE_UPLOAD"
      )
      .map((itemResponse) => itemResponse.getResponse())
      // The response includes the file ids in an array that we can flatten
      .reduce((a, b) => (...a, ...b), ());

    if (files.length > 0) {
      // Each form response has a unique Id
      const subfolderName = response.getId();
      const parentFolder = DriveApp.getFolderById(PARENT_FOLDER_ID);
      const subfolder = parentFolder.createFolder(subfolderName);
      files.forEach((fileId) => {
        // Move each file into the custom folder
        DriveApp.getFileById(fileId).moveTo(subfolder);
      });
    }
  } catch (f) {
    Logger.log(f);
  }
};

8 – Disabling Page Cache for Redirect Response

I’ve implemented a conditional redirect on my site via an event subscriber and returning a redirect response. It’s working but, I believe due to the page_cache module is getting cached for anonymous users.

This is basically what I’m using to set the redirect response:

public function checkRedirectStatus(GetResponseEvent $event) {
    if(shouldIRedirect()) {
        $response = new RedirectResponse('/redirect/path');
        $event->setResponse($response);
     }
}

The above gets cached whether or not it returns true unless I add Drupal::service('page_cache_kill_switch')->trigger();.

As this is a fairly high-traffic page I’m concerned about bypassing cache for anonymous users. Are there other options I’m not aware of?

If this is on the REQUEST kernel event, how far-reaching is page_cache_kill_switch?

Thanks for your help!